*{
  box-sizing:border-box;
}

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

body{
  min-height:100vh;
}

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

.top-bar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  margin-bottom:12px;
}

.title-wrap h1{
  margin:0;
  font-size:clamp(1.5rem,3vw,2.4rem);
}

.subtitle{
  opacity:.8;
}

.hud{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.hud-box{
  background:rgba(0,0,0,.34);
  border:1px solid rgba(255,255,255,.12);
  border-radius:16px;
  padding:10px 14px;
  min-width:92px;
  text-align:center;
  backdrop-filter:blur(10px);
}

.hud-label{
  display:block;
  font-size:.72rem;
  opacity:.75;
  margin-bottom:4px;
}

.table-area{
  flex:1;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  gap:20px;
}

.opponents{
  display:flex;
  justify-content:space-between;
  gap:12px;
}

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

.ai{
  flex:1;
  text-align:center;
}

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

.card-count{
  margin-top:6px;
  font-size:1.2rem;
  color:#ffd166;
  font-weight:900;
}

.mini-stack{
  width:74px;
  height:102px;
  margin:10px auto 0;
  border-radius:14px;
  background-image:url("./cards/card_back.png");
  background-size:cover;
  box-shadow:
    0 10px 20px rgba(0,0,0,.4);
}

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

.battle-info{
  text-align:center;
  margin-bottom:12px;
}

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

.slap-rules{
  opacity:.8;
  margin-top:4px;
}

.pile-area{
  position:relative;
  width:min(300px,70vw);
  height:min(420px,60vh);
  border-radius:28px;
  border:2px dashed rgba(255,255,255,.18);
  background:rgba(0,0,0,.14);
  overflow:visible;
}

.center-card{
  position:absolute;
  width:120px;
  height:168px;
  border-radius:16px;
  background-image:url("./cards/cards.png");
  background-size:1300% 400%;
  box-shadow:
    0 18px 40px rgba(0,0,0,.45);
}

.controls{
  display:flex;
  gap:14px;
  flex-wrap:wrap;
  justify-content:center;
  margin-top:24px;
}

.gold-btn,
.dark-btn{
  border:none;
  border-radius:18px;
  padding:14px 24px;
  font-size:1rem;
  font-weight:900;
  cursor:pointer;
  transition:.2s ease;
}

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

.dark-btn{
  background:rgba(0,0,0,.42);
  color:#fff;
}

.gold-btn:hover,
.dark-btn:hover{
  transform:translateY(-2px);
}

.slap{
  animation:pulse 1.2s infinite;
}

@keyframes pulse{
  0%{
    transform:scale(1);
  }
  50%{
    transform:scale(1.04);
  }
  100%{
    transform:scale(1);
  }
}

.bottom-player{
  padding-bottom:12px;
}

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

.player-deck{
  width:100%;
  min-height:150px;
  display:flex;
  justify-content:center;
  align-items:center;
}

.player-card{
  width:120px;
  height:168px;
  border-radius:16px;
  background-image:url("./cards/card_back.png");
  background-size:cover;
  box-shadow:
    0 18px 40px rgba(0,0,0,.45);
}

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

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

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

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

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

.hidden{
  display:none;
}

.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:clamp(.56rem,1vw,.82rem);
  font-weight:900;
  line-height:1;
}

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

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

@media (max-width:900px){

  body{
    overflow:auto;
  }

  .top-bar{
    flex-direction:column;
    align-items:flex-start;
  }

  .opponents{
    flex-direction:column;
  }

  .pile-area{
    width:90vw;
    height:42vh;
  }

  .center-card{
    width:94px;
    height:132px;
  }

  .player-card{
    width:94px;
    height:132px;
  }

}

@media (max-width:700px){
  html,
  body{
    overflow-y:auto;
  }

  .game-shell{
    min-height:auto;
    padding:10px;
    gap:8px;
  }

  .top-bar{
    margin-bottom:6px;
    gap:8px;
  }

  .subtitle{
    display:none;
  }

  .hud{
    width:100%;
    gap:6px;
  }

  .hud-box{
    flex:1;
    min-width:0;
    padding:7px 8px;
    border-radius:12px;
    font-size:.85rem;
  }

  .table-area{
    gap:8px;
    justify-content:flex-start;
  }

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

  .player{
    border-radius:14px;
    padding:7px;
  }

  .mini-stack{
    width:42px;
    height:58px;
    margin-top:5px;
    border-radius:8px;
  }

  .player-name{
    font-size:.78rem;
  }

  .card-count{
    margin-top:2px;
    font-size:.9rem;
  }

  .center-table{
    flex:none;
    justify-content:flex-start;
  }

  .battle-info{
    margin-bottom:6px;
  }

  .pile-label{
    font-size:.9rem;
  }

  .slap-rules{
    font-size:.72rem;
  }

  .pile-area{
    width:92vw;
    height:210px;
    border-radius:18px;
  }

  .center-card{
    width:74px;
    height:104px;
    border-radius:10px;
  }

  .controls{
    margin-top:10px;
    gap:7px;
  }

  .gold-btn,
  .dark-btn{
    padding:10px 12px;
    border-radius:13px;
    font-size:.82rem;
  }

  .bottom-player{
    padding-bottom:22px;
  }

  .player-deck{
    min-height:92px;
  }

  .player-card{
    width:74px;
    height:104px;
    border-radius:10px;
  }
}

@media (min-width:761px){
  html,
  body{
    height:100%;
    overflow:hidden;
  }

  .game-shell{
    height:100vh;
    min-height:0;
    overflow:hidden;
    padding:10px 14px;
  }

  .top-bar{
    flex:0 0 auto;
  }

  .table-area{
    min-height:0;
    grid-template-rows:auto 1fr auto;
    gap:8px;
  }

  .opponents{
    max-height:96px;
  }

  .player{
    padding:7px;
  }

  .mini-stack{
    width:42px;
    height:58px;
    margin-top:4px;
  }

  .center-table{
    min-height:0;
    justify-content:center;
  }

  .pile-area{
    width:190px;
    height:210px;
    min-height:0;
  }

  .center-card{
    width:72px;
    height:101px;
  }

  .controls{
    margin-top:8px;
  }

  .bottom-player{
    padding-bottom:4px;
  }

  .player-deck{
    min-height:84px;
  }

  .player-card{
    width:72px;
    height:101px;
  }
}

.player-deck,
.pile-area{
  display:flex;
  align-items:center;
  justify-content:center;
}

@media(min-width:761px){
  .pile-area{
    width:240px;
    height:300px;
  }

  .player-deck{
    min-height:128px;
  }

  .bottom-player .player{
    min-height:152px;
  }

  .opponents .player{
    min-height:118px;
  }

  .mini-stack{
    margin-left:auto;
    margin-right:auto;
  }
}

@media(max-width:760px){
  .pile-area{
    width:190px;
    height:220px;
    min-height:220px;
  }

  .player-deck{
    min-height:104px;
  }

  .bottom-player .player{
    min-height:126px;
  }

  .opponents .player{
    min-height:88px;
  }
}

.center-card{
  --card-half-width:41px;
  --card-half-height:57.5px;
}

@media(min-width:761px){
  .center-card{
    --card-half-width:36px;
    --card-half-height:50.5px;
  }
}

@media(max-width:760px){
  .center-card{
    --card-half-width:29px;
    --card-half-height:41px;
  }
}

.top-link,
.top-link:link,
.top-link:visited,
.top-link:hover,
.top-link:active{
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

@media(min-width:761px){
  .top-bar{
    grid-template-columns:auto 1fr auto auto;
  }

  .back-link{
    order:0;
  }

  .title-wrap{
    order:1;
  }

  .top-actions{
    order:2;
  }

  .hud{
    order:3;
  }
}

.ai,
.human{
  display:grid;
  grid-template-rows:auto 1fr;
  align-items:center;
}

.ai .mini-stack,
.human .player-deck{
  align-self:center;
  justify-self:center;
}

.player-deck{
  width:100%;
}

@media(max-width:760px){
  .top-bar{
    grid-template-columns:1fr;
  }

  .back-link{
    order:0;
    width:100%;
  }

  .title-wrap{
    order:1;
  }

  .top-actions{
    order:2;
  }

  .hud{
    order:3;
  }

  .ai,
  .human{
    min-height:118px;
  }
}
