:root{
  --felt:#15a24a;
  --felt2:#0f7f3a;
  --felt3:#085526;
  --panel:rgba(0,0,0,.26);
  --line:rgba(255,255,255,.12);
  --text:#f7fff8;
  --muted:#d7f5df;
  --gold:#ffd166;
  --gold2:#f59f00;
  --shadow:0 24px 70px rgba(0,0,0,.45);
  --card-width:clamp(72px,10vw,128px);
}

*{
  box-sizing:border-box;
  margin:0;
  padding:0;
}

html,
body{
  width:100%;
  max-width:100%;
  min-height:100vh;
  overflow-x:hidden;
  font-family:"Space Grotesk",sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at center,
      #26d96b 0%,
      var(--felt) 22%,
      var(--felt2) 60%,
      var(--felt3) 100%);
}

body{
  touch-action:manipulation;
}

button{
  font-family:inherit;
}

.game-shell{
  width:min(1500px,100%);
  margin:0 auto;
  padding:clamp(10px,2vw,20px);
  display:flex;
  flex-direction:column;
  gap:18px;
}

.topbar{
  display:grid;
  grid-template-columns:auto 1fr auto;
  gap:16px;
  align-items:center;
  background:rgba(0,0,0,.22);
  border:1px solid var(--line);
  border-radius:24px;
  padding:18px;
  backdrop-filter:blur(14px);
  box-shadow:var(--shadow);
}

.back-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:12px 16px;
  border-radius:14px;
  text-decoration:none;
  color:#fff;
  background:rgba(0,0,0,.28);
  border:1px solid var(--line);
}

.title-wrap{
  text-align:center;
}

.title-wrap h1{
  font-size:clamp(2rem,5vw,3.5rem);
  font-weight:900;
  letter-spacing:-.05em;
}

.title-wrap p{
  margin-top:6px;
  color:var(--muted);
}

.top-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.game-btn{
  border:none;
  border-radius:14px;
  padding:12px 18px;
  font-weight:800;
  cursor:pointer;
  color:#1d1200;
  background:
    linear-gradient(
      135deg,
      var(--gold),
      var(--gold2)
    );
}

.hud{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:14px;
}

.hud-card{
  background:rgba(0,0,0,.22);
  border:1px solid var(--line);
  border-radius:20px;
  padding:16px;
  text-align:center;
  backdrop-filter:blur(10px);
  box-shadow:var(--shadow);
}

.hud-card span{
  display:block;
  color:var(--muted);
  font-size:.82rem;
}

.hud-card strong{
  display:block;
  margin-top:8px;
  font-size:clamp(1.4rem,3vw,2rem);
}

.poker-table{
  position:relative;
  background:
    radial-gradient(circle at center,
      #37ef81 0%,
      #18b358 20%,
      #0d8a42 54%,
      #065428 100%);
  border-radius:36px;
  padding:clamp(18px,3vw,34px);
  border:2px solid rgba(255,255,255,.14);
  box-shadow:
    inset 0 2px 10px rgba(255,255,255,.14),
    inset 0 -20px 50px rgba(0,0,0,.22),
    var(--shadow);
  overflow:hidden;
}

.poker-table::before{
  content:"";
  position:absolute;
  inset:0;
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255,255,255,.012) 0px,
      rgba(255,255,255,.012) 2px,
      transparent 2px,
      transparent 6px
    );
  pointer-events:none;
}

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

.paytable div{
  background:rgba(0,0,0,.24);
  border:1px solid rgba(255,255,255,.12);
  border-radius:14px;
  padding:12px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  font-weight:700;
}

.hand{
  margin-top:32px;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  gap:clamp(4px,1vw,14px);
  flex-wrap:nowrap;
}

.card{
  width:var(--card-width);
  aspect-ratio:5/7;
  border-radius:18px;
  position:relative;
  cursor:pointer;
  transition:
    transform .16s ease,
    box-shadow .16s ease;
}

.card:hover{
  transform:translateY(-8px);
}

.card.held{
  transform:translateY(-16px);
}

.card.held::after{
  content:"HELD";
  position:absolute;
  left:50%;
  bottom:-34px;
  transform:translateX(-50%);
  padding:6px 12px;
  border-radius:999px;
  background:#ffd166;
  color:#000;
  font-size:.8rem;
  font-weight:900;
  letter-spacing:.08em;
}

.card-face{
  position:absolute;
  inset:0;
  border-radius:18px;
  overflow:hidden;
  background-image:url("./cards/cards.png");
  background-repeat:no-repeat;
  background-size:1300% 400%;
  box-shadow:0 12px 28px rgba(0,0,0,.45);
}

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

.primary-btn,
.secondary-btn{
  border:none;
  border-radius:16px;
  padding:14px 22px;
  cursor:pointer;
  font-weight:900;
}

.primary-btn{
  color:#000;
  background:
    linear-gradient(
      135deg,
      #ffe08a,
      #ffb703
    );
}

.secondary-btn{
  color:#fff;
  background:rgba(0,0,0,.28);
  border:1px solid rgba(255,255,255,.14);
}

.status{
  margin-top:18px;
  text-align:center;
  color:#ecfff2;
  font-size:1rem;
  font-weight:700;
}

.howto-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.7);
  backdrop-filter:blur(10px);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:1000;
  padding:20px;
}

.howto-overlay.open{
  display:flex;
}

.howto-panel{
  width:min(720px,100%);
  background:
    linear-gradient(
      180deg,
      #13914a,
      #074624
    );
  border-radius:28px;
  border:1px solid rgba(255,255,255,.14);
  padding:28px;
  box-shadow:var(--shadow);
}

.howto-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
}

.close-howto{
  width:46px;
  height:46px;
  border:none;
  border-radius:14px;
  background:rgba(0,0,0,.26);
  color:#fff;
  cursor:pointer;
  font-size:1.2rem;
}

.howto-content{
  margin-top:18px;
}

.howto-content p{
  margin-bottom:16px;
  line-height:1.6;
}

.howto-content ul{
  padding-left:22px;
  display:flex;
  flex-direction:column;
  gap:12px;
  line-height:1.5;
}

@media (max-width:1050px){

  .topbar{
    grid-template-columns:1fr;
    text-align:center;
  }

  .top-actions{
    justify-content:center;
  }

}

@media (max-width:820px){

  :root{
    --card-width:clamp(48px,16vw,90px);
  }

  .hud{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .paytable{
    grid-template-columns:1fr;
  }

}

@media (max-width:520px){

  :root{
    --card-width:clamp(42px,17vw,72px);
  }

  .game-shell{
    padding:8px;
  }

  .hand{
    gap:4px;
  }

  .controls{
    gap:8px;
  }

  .primary-btn,
  .secondary-btn{
    padding:12px 14px;
    font-size:.9rem;
  }

}

.howto-panel{
  max-height:min(86vh,760px);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}

.howto-header{
  flex:0 0 auto;
  position:sticky;
  top:0;
  z-index:5;
}

.howto-content{
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  padding-right:10px;
  max-height:calc(86vh - 90px);
}

@media (max-width:520px){
  .howto-overlay{
    align-items:flex-start;
    padding:10px;
    overflow-y:auto;
  }

  .howto-panel{
    max-height:92vh;
    width:100%;
    padding:18px;
    border-radius:20px;
  }

  .howto-content{
    max-height:calc(92vh - 82px);
  }

  .close-howto{
    flex:0 0 auto;
  }
}


.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;
  box-shadow:0 2px 6px rgba(0,0,0,.22);
  pointer-events:none;
}

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

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

.card-corner-helper .suit{
  margin-top:2px;
}
