*{
  box-sizing:border-box;
}

html,
body{
  margin:0;
  padding:0;
  min-height:100%;
  overflow-x:hidden;
  overflow-y:auto;
  font-family:"Space Grotesk",sans-serif;
  color:#fff;
  background:
    radial-gradient(circle at top,#285c2d 0%,#0d1d10 82%);
}

body{
  min-height:100vh;
}

.game-shell{
  min-height:100vh;
  padding:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.top-bar{
  display:grid;
  grid-template-columns:auto 1fr auto;
  gap:10px;
  align-items:center;
}

.title-wrap h1{
  margin:0;
  font-size:clamp(1.3rem,2.6vw,2.2rem);
}

.subtitle{
  opacity:.8;
  font-size:.84rem;
}

.top-actions{
  display:flex;
  gap:8px;
  align-items:center;
}

.dark-btn,
.gold-btn,
.mode-select{
  border:none;
  border-radius:14px;
  padding:11px 16px;
  font-family:"Space Grotesk",sans-serif;
  font-size:.9rem;
  font-weight:900;
}

.dark-btn{
  background:rgba(0,0,0,.4);
  color:#fff;
  border:1px solid rgba(255,255,255,.1);
  cursor:pointer;
}

.gold-btn{
  background:
    linear-gradient(
      180deg,
      #ffe29a,
      #d7a93d
    );
  color:#2b1a00;
  cursor:pointer;
}

.mode-select{
  background:#fff;
  color:#111;
}

.top-link,
.top-link:link,
.top-link:visited,
.top-link:hover,
.top-link:active{
  text-decoration:none;
}

.table-area{
  flex:1;
  display:grid;
  grid-template-rows:auto 1fr auto auto;
  gap:10px;
}

.opponents{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
}

.player{
  background:rgba(0,0,0,.28);
  border:1px solid rgba(255,255,255,.08);
  border-radius:18px;
  padding:10px;
  backdrop-filter:blur(10px);
}

.player-name{
  font-weight:900;
  letter-spacing:.08em;
}

.card-count{
  margin-top:4px;
  color:#ffd166;
  font-weight:900;
}

.mini-stack{
  width:54px;
  height:76px;
  margin:8px auto 0;
  border-radius:10px;
  background-image:url("./cards/card_back.png");
  background-size:cover;
  background-position:center;
  box-shadow:
    0 10px 24px rgba(0,0,0,.4);
}

.center-table{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:12px;
}

.battle-info{
  text-align:center;
}

.pile-label{
  font-size:1rem;
  font-weight:900;
}

.slap-rules{
  opacity:.8;
  font-size:.78rem;
  margin-top:4px;
}

.center-pile{
  position:relative;
  width:min(260px,72vw);
  height:min(320px,42vh);
  min-height:240px;
  border-radius:24px;
  background:
    radial-gradient(circle at center,
    rgba(43,102,51,.95) 0%,
    rgba(17,48,22,.98) 100%);
  border:2px solid rgba(255,255,255,.08);
  box-shadow:
    inset 0 0 40px rgba(0,0,0,.35),
    0 20px 40px rgba(0,0,0,.35);
}

.george-card,
.play-card{
  position:relative;
  border-radius:12px;
  overflow:hidden;
  background-image:url("./cards/cards.png");
  background-size:1300% 400%;
  box-shadow:
    0 16px 30px rgba(0,0,0,.45);
}

.george-card{
  position:absolute;
  width:92px;
  height:128px;
}

.play-card{
  width:92px;
  height:128px;
  min-width:92px;
  margin-left:-56px;
  cursor:pointer;
  transition:
    transform .15s ease,
    box-shadow .15s ease;
}

.play-card:first-child{
  margin-left:0;
}

.play-card:hover{
  transform:
    translateY(-16px)
    scale(1.05);
  z-index:100;
}

.play-card.playable{
  outline:4px solid rgba(255,255,255,.75);
  outline-offset:-4px;
}

.player-hand{
  min-height:120px;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow-x:auto;
  overflow-y:hidden;
  padding:6px 0 10px;
  scrollbar-width:none;
}

.player-hand::-webkit-scrollbar{
  display:none;
}

.player-hand-inner{
  display:flex;
  align-items:center;
  justify-content:center;
}

.controls{
  display:flex;
  justify-content:center;
}

.action-feed-wrap{
  text-align:center;
  background:rgba(0,0,0,.28);
  border:1px solid rgba(255,255,255,.08);
  border-radius:18px;
  padding:10px 14px;
}

.action-feed-title{
  font-size:.68rem;
  opacity:.7;
  text-transform:uppercase;
  letter-spacing:.08em;
  font-weight:900;
  margin-bottom:4px;
}

.action-feed{
  color:#ffd166;
  font-weight:900;
  min-height:24px;
}

.player-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:8px;
}

.card-corner-helper{
  position:absolute;
  top:4px;
  left:4px;
  z-index:50;
  min-width:22px;
  padding:3px 5px;
  border-radius:8px;
  background:rgba(255,255,255,.96);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  font-size:.62rem;
  font-weight:900;
  line-height:1;
  pointer-events:none;
}

.card-corner-helper.red{
  color:#d3152a;
}

.card-corner-helper.black{
  color:#111;
}

.instructions-overlay{
  position:fixed;
  inset:0;
  z-index:999;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.72);
  padding:14px;
}

.instructions-modal{
  position:relative;
  width:min(92vw,700px);
  max-height:88vh;
  overflow:hidden;
  border-radius:24px;
  background:#18241a;
  border:1px solid rgba(255,255,255,.12);
}

.instructions-modal h2{
  margin:0;
  padding:20px;
}

.instructions-scroll{
  max-height:70vh;
  overflow:auto;
  padding:0 20px 24px;
}

.close-btn{
  position:absolute;
  top:12px;
  right:12px;
  width:42px;
  height:42px;
  border:none;
  border-radius:50%;
  background:#fff;
  cursor:pointer;
}

.hidden{
  display:none;
}

.toast{
  position:fixed;
  left:50%;
  bottom:18px;
  transform:translateX(-50%);
  z-index:9999;
  background:rgba(0,0,0,.84);
  color:#fff;
  padding:12px 18px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.12);
  backdrop-filter:blur(10px);
  font-weight:900;
}

@media(max-width:760px){

  .top-bar{
    grid-template-columns:1fr;
  }

  .top-actions{
    flex-wrap:wrap;
  }

  .dark-btn,
  .gold-btn,
  .mode-select{
    flex:1;
  }

  .subtitle{
    display:none;
  }

  .center-pile{
    width:190px;
    height:240px;
    min-height:220px;
  }

  .george-card{
    width:68px;
    height:96px;
  }

  .play-card{
    width:68px;
    height:96px;
    min-width:68px;
    margin-left:-42px;
  }

  .player-hand{
    min-height:96px;
  }

  .card-corner-helper{
    min-width:18px;
    padding:2px 4px;
    font-size:.5rem;
  }

}

.mode-chip-wrap{
  position:relative;
}

.mode-chip{
  min-width:190px;
  border:none;
  border-radius:999px;
  padding:11px 15px;
  display:inline-flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  font-family:"Space Grotesk",sans-serif;
  font-size:.9rem;
  font-weight:900;
  color:#fff;
  background:
    linear-gradient(180deg,rgba(255,255,255,.16),rgba(0,0,0,.34));
  border:1px solid rgba(255,255,255,.16);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.2),
    0 10px 22px rgba(0,0,0,.22);
  cursor:pointer;
}

.mode-chevron{
  font-size:1rem;
  opacity:.8;
}

.mode-menu{
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  z-index:500;
  min-width:220px;
  padding:8px;
  border-radius:18px;
  background:rgba(5,20,10,.96);
  border:1px solid rgba(255,255,255,.14);
  box-shadow:0 18px 36px rgba(0,0,0,.4);
  backdrop-filter:blur(14px);
}

.mode-menu button{
  width:100%;
  border:none;
  border-radius:12px;
  padding:11px 12px;
  background:transparent;
  color:#fff;
  text-align:left;
  font-family:"Space Grotesk",sans-serif;
  font-weight:900;
  cursor:pointer;
}

.mode-menu button:hover{
  background:rgba(255,255,255,.1);
}

.mode-select{
  display:none !important;
}

.player.active-turn{
  border-color:rgba(255,209,102,.72);
  box-shadow:0 0 26px rgba(255,209,102,.22);
}

@media(max-width:760px){
  .mode-chip{
    width:100%;
    min-width:0;
  }

  .mode-menu{
    left:0;
    right:0;
    min-width:0;
  }
}

.george-rules-modal{
  width:min(94vw,860px);
}

.george-rules-modal h2{
  padding:22px 24px 12px;
}

.rules-toc{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  padding:0 24px 14px;
  border-bottom:1px solid rgba(255,255,255,.1);
}

.rules-toc a{
  color:#111;
  background:linear-gradient(180deg,#ffe29a,#d7a93d);
  text-decoration:none;
  border-radius:999px;
  padding:8px 12px;
  font-size:.78rem;
  font-weight:900;
}

.instructions-scroll{
  scroll-behavior:smooth;
}

.instructions-scroll section{
  padding:8px 0 18px;
  border-bottom:1px solid rgba(255,255,255,.08);
}

.instructions-scroll h3{
  color:#ffd166;
  font-size:1.15rem;
  margin-top:10px;
}

.instructions-scroll h4{
  color:#fff;
  margin-bottom:4px;
}

.instructions-scroll p,
.instructions-scroll li{
  line-height:1.55;
  font-size:.98rem;
}

.rule-example{
  background:rgba(0,0,0,.34);
  border:1px solid rgba(255,255,255,.1);
  border-radius:14px;
  padding:12px;
  color:#ffd166;
  font-weight:900;
  text-align:center;
}

@media(max-width:760px){
  .rules-toc{
    padding:0 16px 12px;
  }

  .rules-toc a{
    flex:1 1 calc(50% - 8px);
    text-align:center;
  }

  .george-rules-modal h2{
    padding-left:16px;
  }

  .instructions-scroll p,
  .instructions-scroll li{
    font-size:.92rem;
  }
}

html,
body{
  background:
    radial-gradient(circle at 50% 18%,rgba(70,145,72,.95) 0%,rgba(28,91,45,.98) 42%,rgba(11,45,25,1) 100%) !important;
}

.game-shell{
  background:
    radial-gradient(circle at 50% 28%,rgba(62,139,69,.38),rgba(0,0,0,0) 58%),
    linear-gradient(180deg,rgba(255,255,255,.035),rgba(0,0,0,.08)) !important;
}

.bottom-player .player,
.action-feed-wrap,
.player{
  background:rgba(0,0,0,.24) !important;
}

.center-pile{
  background:
    radial-gradient(circle at center,rgba(46,128,61,.95),rgba(16,70,35,.96)) !important;
}

.bottom-player .human{
  min-height:170px;
}

.player-hand{
  justify-content:flex-start !important;
  padding:8px 18px 14px !important;
  overflow-x:auto !important;
}

.player-hand-inner{
  justify-content:flex-start !important;
  min-width:max-content;
  margin:0 auto;
}

.play-card{
  margin-left:-22px !important;
}

.play-card:first-child{
  margin-left:0 !important;
}

@media(max-width:760px){
  .player-hand{
    padding:8px 12px 14px !important;
  }

  .play-card{
    margin-left:-16px !important;
  }
}

.hand-scroll-wrap{
  display:grid;
  grid-template-columns:auto 1fr auto;
  align-items:center;
  gap:8px;
  width:100%;
}

.hand-arrow{
  width:42px;
  height:72px;
  border:none;
  border-radius:14px;
  background:rgba(0,0,0,.42);
  color:#fff;
  font-size:2rem;
  font-weight:900;
  cursor:pointer;
  border:1px solid rgba(255,255,255,.12);
}

.hand-arrow:hover{
  background:rgba(255,255,255,.12);
}

.player-hand{
  justify-content:flex-start !important;
  overflow-x:auto !important;
  overflow-y:hidden !important;
  padding:10px 8px 16px !important;
  scroll-behavior:smooth;
}

.player-hand-inner{
  justify-content:flex-start !important;
  gap:10px !important;
  min-width:max-content !important;
  margin:0 !important;
}

.play-card{
  margin-left:0 !important;
  flex:0 0 auto !important;
}

@media(max-width:760px){
  .hand-arrow{
    width:34px;
    height:58px;
    font-size:1.6rem;
  }

  .player-hand-inner{
    gap:7px !important;
  }
}

.bottom-player .human{
  min-height:170px !important;
  overflow:visible !important;
}

.hand-scroll-wrap{
  grid-template-columns:auto minmax(0,1fr) auto !important;
  overflow:visible !important;
}

.player-hand{
  width:100% !important;
  max-width:100% !important;
  min-width:0 !important;
  overflow-x:auto !important;
  overflow-y:visible !important;
  justify-content:flex-start !important;
  padding:10px 14px 18px !important;
}

.player-hand-inner{
  width:max-content !important;
  min-width:max-content !important;
  max-width:none !important;
  display:flex !important;
  flex-wrap:nowrap !important;
  gap:12px !important;
  margin:0 !important;
  padding:0 !important;
  justify-content:flex-start !important;
  align-items:center !important;
}

.play-card{
  width:92px !important;
  height:128px !important;
  min-width:92px !important;
  flex:0 0 92px !important;
  margin:0 !important;
  position:relative !important;
  left:auto !important;
  top:auto !important;
  transform:none !important;
}

.play-card:hover{
  transform:translateY(-10px) scale(1.03) !important;
}

@media(max-width:760px){
  .play-card{
    width:68px !important;
    height:96px !important;
    min-width:68px !important;
    flex-basis:68px !important;
  }

  .player-hand-inner{
    gap:8px !important;
  }
}

.mode-menu{
  background:
    linear-gradient(
      180deg,
      rgba(48,110,62,.72),
      rgba(14,46,25,.62)
    ) !important;

  backdrop-filter:blur(22px) saturate(160%) !important;
  -webkit-backdrop-filter:blur(22px) saturate(160%) !important;

  border:1px solid rgba(255,255,255,.14) !important;

  box-shadow:
    0 20px 40px rgba(0,0,0,.28),
    inset 0 1px 0 rgba(255,255,255,.12) !important;

  padding:10px !important;
  border-radius:22px !important;
}

.mode-menu button{
  background:transparent !important;
  color:#fff !important;

  font-size:1rem !important;
  font-weight:900 !important;

  padding:14px 16px !important;

  border-radius:14px !important;

  transition:
    background .14s ease,
    transform .12s ease;
}

.mode-menu button:hover{
  background:rgba(255,255,255,.12) !important;
  transform:translateX(2px);
}

.mode-menu button:active{
  transform:scale(.98);
}

.mode-chip{
  backdrop-filter:blur(16px) saturate(160%);
  -webkit-backdrop-filter:blur(16px) saturate(160%);
}

@media(max-width:760px){

  .mode-menu button{
    font-size:.96rem !important;
    padding:13px 14px !important;
  }

}

html,
body{
  background:
    radial-gradient(circle at 50% 18%,rgba(70,145,72,.95) 0%,rgba(28,91,45,.98) 42%,rgba(11,45,25,1) 100%) !important;
}

.game-shell{
  background:
    radial-gradient(circle at 50% 28%,rgba(62,139,69,.36),rgba(0,0,0,0) 58%),
    linear-gradient(180deg,rgba(255,255,255,.03),rgba(0,0,0,.08)) !important;
}

.palace-table{
  margin-bottom:10px;
  display:grid;
  gap:8px;
}

.table-label{
  text-align:center;
  font-size:.72rem;
  opacity:.78;
  font-weight:900;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.palace-row{
  display:flex;
  justify-content:center;
  gap:10px;
  min-height:104px;
}

.palace-card,
.palace-table-card{
  width:72px !important;
  height:101px !important;
  min-width:72px !important;
  border-radius:10px;
}

.palace-table-card{
  position:relative !important;
  left:auto !important;
  top:auto !important;
  cursor:pointer;
}

.center-pile{
  background:
    radial-gradient(circle at center,rgba(46,128,61,.95),rgba(16,70,35,.96)) !important;
  border:2px solid rgba(255,255,255,.08) !important;
  box-shadow:
    inset 0 0 40px rgba(0,0,0,.35),
    0 20px 40px rgba(0,0,0,.35),
    0 0 30px rgba(80,180,100,.16) !important;
}

.play-card.playable,
.palace-table-card.playable{
  outline:4px solid rgba(255,255,255,.78);
  outline-offset:-4px;
  box-shadow:
    0 0 24px rgba(120,255,160,.28),
    0 16px 30px rgba(0,0,0,.45) !important;
}

.player.active-turn{
  border-color:rgba(255,209,102,.72) !important;
  box-shadow:0 0 26px rgba(255,209,102,.22) !important;
}

@media(max-width:760px){
  .palace-row{
    gap:7px;
    min-height:86px;
  }

  .palace-card,
  .palace-table-card{
    width:58px !important;
    height:82px !important;
    min-width:58px !important;
  }
}

/* Palace compact full-board layout */
.table-area{
  grid-template-rows:auto minmax(150px, .7fr) auto auto !important;
  gap:6px !important;
}

.center-table{
  gap:6px !important;
  justify-content:center !important;
  min-height:0 !important;
}

.battle-info{
  margin-bottom:0 !important;
}

.pile-label{
  font-size:.82rem !important;
}

.slap-rules{
  font-size:.68rem !important;
  margin-top:2px !important;
}

.center-pile{
  width:170px !important;
  height:150px !important;
  min-height:150px !important;
  border-radius:18px !important;
}

.center-pile .palace-card,
.center-pile .george-card{
  width:58px !important;
  height:82px !important;
  min-width:58px !important;
}

.controls{
  margin-top:0 !important;
}

.action-feed-wrap{
  padding:7px 10px !important;
}

.action-feed-title{
  margin-bottom:2px !important;
}

.bottom-player .human{
  min-height:auto !important;
}

.palace-table{
  gap:5px !important;
  margin-bottom:6px !important;
}

.table-label{
  font-size:.62rem !important;
}

.palace-row{
  min-height:78px !important;
}

.palace-card,
.palace-table-card{
  width:54px !important;
  height:76px !important;
  min-width:54px !important;
}

.player-hand{
  min-height:86px !important;
  padding-top:4px !important;
  padding-bottom:6px !important;
}

.play-card{
  width:58px !important;
  height:82px !important;
  min-width:58px !important;
  flex-basis:58px !important;
}

@media(max-width:760px){
  .game-shell{
    padding:6px !important;
    gap:5px !important;
  }

  .opponents{
    gap:5px !important;
  }

  .player{
    padding:6px !important;
  }

  .center-pile{
    width:150px !important;
    height:128px !important;
    min-height:128px !important;
  }

  .center-pile .palace-card,
  .center-pile .george-card{
    width:48px !important;
    height:68px !important;
    min-width:48px !important;
  }

  .palace-row{
    min-height:68px !important;
  }

  .palace-card,
  .palace-table-card{
    width:48px !important;
    height:68px !important;
    min-width:48px !important;
  }

  .play-card{
    width:50px !important;
    height:70px !important;
    min-width:50px !important;
    flex-basis:50px !important;
  }

  .player-hand{
    min-height:76px !important;
  }
}

/* Palace spacing fix: prevent rule/buttons/action collisions */
.center-table{
  gap:9px !important;
  padding-top:8px !important;
}

.battle-info{
  min-height:38px !important;
  margin-bottom:4px !important;
}

.slap-rules{
  display:block !important;
  max-width:min(92vw,520px) !important;
  margin:4px auto 0 !important;
  line-height:1.2 !important;
  white-space:normal !important;
}

.center-pile{
  margin-top:4px !important;
}

.controls{
  margin-top:6px !important;
  margin-bottom:6px !important;
}

.action-feed-wrap{
  margin-top:6px !important;
}

.table-area{
  gap:9px !important;
}

@media(max-width:760px){
  .center-table{
    gap:7px !important;
    padding-top:6px !important;
  }

  .battle-info{
    min-height:42px !important;
  }

  .slap-rules{
    font-size:.62rem !important;
    line-height:1.18 !important;
  }

  .controls{
    margin-top:7px !important;
    margin-bottom:7px !important;
  }

  .action-feed-wrap{
    margin-top:7px !important;
  }
}

/* Palace final fit: shorter YOU area + safer green felt spacing */
.game-shell{
  padding-bottom:8px !important;
}

.table-area{
  grid-template-rows:auto minmax(165px,.8fr) auto auto !important;
}

.bottom-player .human{
  padding:6px 8px !important;
  min-height:0 !important;
}

.player-header{
  margin-bottom:3px !important;
}

.bottom-player .player-name,
.bottom-player .card-count{
  font-size:.78rem !important;
  line-height:1 !important;
}

.palace-table{
  gap:3px !important;
  margin-bottom:4px !important;
}

.table-label{
  font-size:.55rem !important;
  line-height:1 !important;
}

.palace-row{
  min-height:58px !important;
}

.palace-card,
.palace-table-card{
  width:42px !important;
  height:59px !important;
  min-width:42px !important;
  border-radius:7px !important;
}

.hand-scroll-wrap{
  gap:5px !important;
}

.hand-arrow{
  height:46px !important;
  width:30px !important;
  font-size:1.35rem !important;
  border-radius:10px !important;
}

.player-hand{
  min-height:62px !important;
  padding:3px 6px 4px !important;
}

.play-card{
  width:42px !important;
  height:59px !important;
  min-width:42px !important;
  flex-basis:42px !important;
  border-radius:7px !important;
}

.player-hand-inner{
  gap:5px !important;
}

.card-corner-helper{
  top:2px !important;
  left:2px !important;
  min-width:14px !important;
  padding:1px 3px !important;
  font-size:.42rem !important;
  border-radius:5px !important;
}

.center-table{
  padding-top:10px !important;
  padding-bottom:6px !important;
}

.center-pile{
  margin-top:5px !important;
  margin-bottom:5px !important;
}

.controls{
  margin-top:8px !important;
  margin-bottom:8px !important;
}

.action-feed-wrap{
  margin-top:8px !important;
  margin-bottom:2px !important;
}

@media(max-width:760px){
  .game-shell{
    padding:6px !important;
    padding-bottom:7px !important;
  }

  .bottom-player .human{
    padding:5px 6px !important;
  }

  .palace-row{
    min-height:52px !important;
  }

  .palace-card,
  .palace-table-card,
  .play-card{
    width:38px !important;
    height:54px !important;
    min-width:38px !important;
    flex-basis:38px !important;
  }

  .player-hand{
    min-height:56px !important;
  }

  .hand-arrow{
    height:42px !important;
    width:28px !important;
  }

  .center-table{
    padding-top:9px !important;
  }
}
