:root {
  --sweeple-green: #54bf98;
  --sweeple-green-dark: #23745e;
  --sweeple-yellow: #f5d64d;
  --sweeple-blue: #77b6e8;
  --sweeple-ink: #243742;
}

body {
  background:
    radial-gradient(circle at 20% 8%, rgba(116, 203, 176, .14), transparent 27rem),
    linear-gradient(145deg, #f8f8fb, #edf1f7);
}

.sweeple-shell {
  width: min(100%, 42rem);
  height: var(--game-visible-height, 100dvh);
  min-height: 0;
  margin: 0 auto;
  padding: max(.8rem, env(safe-area-inset-top)) clamp(.75rem, 3vw, 1.2rem) max(.65rem, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: .55rem;
  overflow: hidden;
}

.sweeple-header {
  width: min(100%, 35rem);
  min-width: 0;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
}

.sweeple-header > div { min-width: 0; }
.eyebrow {
  display: block;
  margin: 0 0 .14rem;
  color: #55b99a;
  font-size: clamp(.62rem, 2.5vw, .72rem);
  font-weight: 850;
  letter-spacing: .16em;
}
.sweeple-header h1 {
  margin: 0;
  overflow: hidden;
  color: #246b5a;
  font-family: inherit;
  font-size: clamp(1.28rem, 5.8vw, 2rem);
  font-weight: 950;
  letter-spacing: -.035em;
  line-height: 1.02;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.quit-link {
  width: auto;
  min-width: 5.2rem;
  padding: 0 .85rem;
  gap: .35rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(145deg, #79ceb1, #51b694);
  color: white;
  box-shadow: 0 .35rem .8rem rgba(35, 116, 94, .24);
  font-size: 1.1rem;
}
.quit-link span { font-size: .8rem; }

.game-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.start-card, .queue-card {
  width: min(100%, 31rem);
  padding: clamp(1.2rem, 6vw, 2rem);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 1.9rem;
  background: rgba(255,255,255,.7);
  box-shadow: 0 1.3rem 3rem rgba(63, 91, 119, .14), inset 0 1px rgba(255,255,255,.85);
  text-align: center;
  backdrop-filter: blur(18px);
}
.start-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto .9rem;
  display: grid;
  place-items: center;
  border-radius: 1.25rem;
  background: linear-gradient(145deg, #8ed8bf, #4eb694);
  color: white;
  font-size: 2rem;
  box-shadow: 0 .7rem 1.4rem rgba(36, 115, 91, .23);
}
.start-card h2, .queue-card h2 {
  margin: .25rem 0 .7rem;
  color: var(--sweeple-ink);
  font-family: inherit;
  font-size: clamp(1.5rem, 6vw, 2.15rem);
  line-height: 1.12;
  letter-spacing: -.04em;
}
.start-copy, .queue-card p {
  margin: 0 auto 1rem;
  color: #6d7882;
  line-height: 1.5;
}
.rule-pills {
  margin: 0 0 1.2rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .4rem;
  list-style: none;
}
.rule-pills li {
  padding: .38rem .62rem;
  border-radius: 999px;
  background: #e9f6f1;
  color: #27735d;
  font-size: .68rem;
  font-weight: 850;
}
.connection-note { min-height: 1.2rem; color: #bd5060 !important; font-size: .75rem; }
.start-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.start-actions .action-button { border: 0; border-radius: 999px; box-shadow: 0 .45rem .9rem rgba(42, 79, 105, .12); }
.start-actions .primary { background: var(--sweeple-green); color: white; }
.bot-button { background: var(--sweeple-yellow); }

.radar {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  display: block;
  border: .45rem solid #ddf3eb;
  border-top-color: var(--sweeple-green);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

.match-view {
  width: min(100%, 35rem);
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .34rem;
}
.match-view[hidden] { display: none; }
.start-card[hidden] { display: none; }

.players-row {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-rows: auto .9rem auto;
  align-items: center;
}

.player-card {
  min-width: 0;
  padding: .62rem .8rem .7rem;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 1.5rem;
  box-shadow: 0 .55rem 1.25rem rgba(58, 83, 106, .16), inset 0 1px rgba(255,255,255,.4);
  color: white;
  transition: filter .18s ease, transform .18s ease;
}
.player-card-you {
  background: linear-gradient(105deg, #4bb58f, #70cbaa);
  animation: active-seat-pulse 2.4s ease-in-out infinite;
}
.player-card-rival { background: linear-gradient(105deg, #efcd39, #f7dd5c); color: #fffef7; }
.player-card.stunned { filter: saturate(.75); animation: stunned-card .55s ease infinite alternate; }
.player-card.mine-revealed { animation: opponent-alert .48s ease; }
.player-heading { min-width: 0; display: flex; align-items: center; gap: .6rem; }
.player-heading img {
  width: 2.35rem;
  height: 2.35rem;
  flex: none;
  border: 2px solid rgba(255,255,255,.75);
  border-radius: 50%;
  background: white;
  object-fit: cover;
}
.player-heading > div:nth-child(2) { min-width: 0; display: flex; align-items: center; gap: .45rem; }
.player-heading strong { overflow: hidden; font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.player-heading > div:nth-child(2) span {
  padding: .13rem .34rem;
  border-radius: 999px;
  background: rgba(255,255,255,.2);
  font-size: .55rem;
  font-weight: 950;
}
.hit-dots { margin-left: auto; display: flex; gap: .34rem; }
.hit-dot {
  width: 1.55rem;
  height: 1.55rem;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 50%;
  box-shadow: inset 0 0 0 .36rem rgba(255,255,255,.1);
}
.hit-dot.hit { background: #f36572; box-shadow: inset 0 0 0 .36rem rgba(255,255,255,.2); }
.progress-copy { margin: .42rem 0 .28rem; display: flex; justify-content: space-between; gap: .6rem; font-size: .68rem; }
.progress-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-copy strong { font-size: .78rem; }
.progress-track { height: .42rem; overflow: hidden; border: 1px solid rgba(255,255,255,.28); border-radius: 99px; background: rgba(255,255,255,.18); }
.progress-track span { height: 100%; display: block; border-radius: inherit; background: rgba(255,255,255,.82); transition: width .24s ease; }

.versus-pill {
  z-index: 2;
  justify-self: center;
  padding: .13rem .8rem;
  border-radius: 999px;
  background: rgba(255,255,255,.88);
  color: #5b6270;
  box-shadow: 0 .2rem .5rem rgba(64, 84, 105, .1);
  font-size: .65rem;
  font-weight: 950;
  letter-spacing: .12em;
}

.match-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.match-metric {
  min-height: 3.15rem;
  padding: .55rem .75rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .5rem;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 1.35rem;
  background: rgba(255,255,255,.62);
  box-shadow: 0 .4rem 1rem rgba(58, 83, 106, .1), inset 0 1px rgba(255,255,255,.85);
}
.metric-icon { width: 1.65rem; height: 1.65rem; display: grid; place-items: center; border-radius: 50%; font-weight: 950; }
.time-metric .metric-icon { background: #d8f2fb; color: #46a8d3; }
.mine-metric .metric-icon { background: #ffe1df; color: #e76265; }
.metric-name { color: #858991; font-size: .66rem; font-weight: 900; letter-spacing: .15em; }
.match-metric strong { color: #28343d; font-size: 1.55rem; font-variant-numeric: tabular-nums; }

.board-slot {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  align-self: stretch;
  place-items: center;
  container-type: size;
}
.board-wrap {
  position: relative;
  width: min(100cqw, 100cqh);
  max-width: 100%;
  aspect-ratio: 1;
  padding: clamp(.3rem, 1.4vw, .48rem);
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 1.6rem;
  background: rgba(255,255,255,.58);
  box-shadow: 0 .8rem 1.8rem rgba(62, 91, 119, .14), inset 0 1px rgba(255,255,255,.9);
  container-type: size;
}
.match-view > .board-wrap {
  width: min(100%, calc(100cqh - 19rem));
  justify-self: center;
}
.mine-grid { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(10, 1fr); gap: clamp(.12rem, .75cqw, .28rem); }
.mine-cell {
  min-width: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: clamp(.23rem, 1.35cqw, .52rem);
  background: linear-gradient(145deg, #91c8ef, #69a9de);
  box-shadow: inset 0 1px 2px rgba(255,255,255,.58), inset 0 -3px 7px rgba(39,104,166,.18), 0 2px 4px rgba(72,112,151,.12);
  color: white;
  font-size: clamp(.58rem, 4cqw, 1.12rem);
  font-weight: 950;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, filter .12s ease;
}
.mine-cell:not(:disabled):active { transform: scale(.86); filter: brightness(1.07); }
.mine-cell.open {
  background: linear-gradient(145deg, #edf4fb, #dce9f6);
  box-shadow: inset 0 1px 2px rgba(255,255,255,.85), inset 0 -2px 5px rgba(73,111,151,.08);
}
.mine-cell[data-number="1"] { color: #2f6bd2; }
.mine-cell[data-number="2"] { color: #26aa69; }
.mine-cell[data-number="3"] { color: #ec5058; }
.mine-cell[data-number="4"] { color: #8e48b7; }
.mine-cell[data-number="5"], .mine-cell[data-number="6"], .mine-cell[data-number="7"], .mine-cell[data-number="8"] { color: #a42e51; }
.mine-cell.mine-hit { background: linear-gradient(145deg, #ff8992, #ea5965); color: #7b1120; animation: mine-pop .35s ease; }
.mine-cell.rival-mine { background: linear-gradient(145deg, #ffe987, #f2c742); color: #9b5c00; animation: rival-mine .5s ease; }
.board-wrap.needs-opening .mine-cell:not(.opening-tile) { filter: saturate(.72) brightness(.92); }
.mine-cell.opening-tile {
  position: relative;
  z-index: 1;
  background: linear-gradient(145deg, #74d5b1, #42ad88);
  color: white;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,.65),
    inset 0 -3px 7px rgba(25,105,80,.18),
    0 0 0 .18rem rgba(255,255,255,.9),
    0 0 0 .34rem rgba(84,191,152,.55),
    0 .2rem .8rem rgba(36,130,99,.32);
  animation: opening-tile-pulse 1.15s ease-in-out infinite alternate;
}
.board-wrap.is-stunned .mine-grid { filter: grayscale(.25) blur(.4px); pointer-events: none; }
.stun-message, .countdown {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 3;
  translate: -50% -50%;
  border-radius: 999px;
  box-shadow: 0 .5rem 1.2rem rgba(56, 64, 75, .2);
  font-weight: 950;
  pointer-events: none;
}
.stun-message[hidden], .countdown[hidden] { display: none; }
.stun-message { padding: .55rem .8rem; background: #f05f6d; color: white; font-size: .75rem; letter-spacing: .08em; }
.countdown {
  inset: .7rem auto auto 50%;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  translate: -50% 0;
  background: rgba(255,255,255,.92);
  color: #27866b;
  font-size: 1.45rem;
}
.match-notice { min-height: 1rem; margin: 0; overflow: hidden; color: #78838c; font-size: .68rem; font-weight: 750; text-align: center; text-overflow: ellipsis; white-space: nowrap; }

.mine-shake { animation: mine-shake .42s ease; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes mine-pop { 50% { transform: scale(.72) rotate(5deg); } }
@keyframes rival-mine { 45% { transform: scale(1.12); filter: brightness(1.15); } }
@keyframes mine-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@keyframes stunned-card { to { filter: saturate(.75) brightness(.88); } }
@keyframes opponent-alert { 45% { transform: scale(1.018); filter: brightness(1.08); } }
@keyframes active-seat-pulse { 50% { box-shadow: 0 .55rem 1.4rem rgba(54, 173, 134, .26), inset 0 1px rgba(255,255,255,.5); } }
@keyframes opening-tile-pulse { to { transform: scale(1.08); filter: brightness(1.08); } }

@media (max-height: 850px) and (orientation: portrait) {
  .sweeple-shell { padding-top: max(.45rem, env(safe-area-inset-top)); gap: .3rem; }
  .sweeple-header h1 { font-size: clamp(1.05rem, 5vw, 1.45rem); }
  .quit-link { min-width: 4.4rem; height: 2.55rem; min-height: 2.55rem; }
  .match-view { gap: .2rem; }
  .player-card { padding: .42rem .65rem .48rem; border-radius: 1.15rem; }
  .player-heading img { width: 1.8rem; height: 1.8rem; }
  .hit-dot { width: 1.2rem; height: 1.2rem; }
  .progress-copy { margin: .25rem 0 .18rem; font-size: .58rem; }
  .progress-track { height: .3rem; }
  .match-metric { min-height: 2.5rem; padding: .35rem .65rem; }
  .match-metric strong { font-size: 1.2rem; }
  .metric-icon { width: 1.35rem; height: 1.35rem; }
  .board-wrap { border-radius: 1.25rem; }
}

@media (min-width: 700px) and (max-height: 900px) and (orientation: landscape) {
  .players-row { grid-template-columns: 1fr 1fr; grid-template-rows: auto; gap: .55rem; }
  .versus-pill {
    position: absolute;
    inset: 50% auto auto 50%;
    translate: -50% -50%;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .sweeple-shell.game-shell { width: 100%; max-width: none; padding: .3rem max(.5rem, env(safe-area-inset-right)) .3rem max(.5rem, env(safe-area-inset-left)); grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr); gap: .3rem; }
  .sweeple-header { width: 100%; grid-column: 1; grid-row: 1; }
  .sweeple-header h1 { font-size: 1rem; }
  .eyebrow { margin: 0; font-size: .5rem; }
  .quit-link { min-width: 3.6rem; min-height: 2rem; height: 2rem; padding-inline: .5rem; }
  .sweeple-shell > .game-stage { grid-column: 1; grid-row: 2; place-items: stretch; }
  .start-card, .queue-card { width: min(100%, 58rem); height: 100%; padding: .55rem .75rem; border-radius: 1rem; display: grid; grid-template-columns: 5rem minmax(13rem, .85fr) minmax(15rem, 1fr); grid-template-rows:auto auto minmax(0,1fr) auto; align-items:center; gap:.25rem .7rem; text-align:left; }
  .queue-card[hidden] { display: none; }
  .start-icon, .radar { grid-column:1; grid-row:1/-1; width:3rem; height:3rem; margin:auto; font-size:1.35rem; }
  .start-card > .eyebrow, .queue-card > .eyebrow { grid-column:2; margin:0; }
  .start-card h2, .queue-card h2 { grid-column:2; margin:0; font-size:1.25rem; }
  .start-copy, .queue-card p:not(.eyebrow) { grid-column:2; margin:0; font-size:.7rem; line-height:1.25; }
  .rule-pills { grid-column:3; grid-row:1; margin:0; justify-content:flex-start; }
  .rule-pills li { padding:.25rem .45rem; font-size:.56rem; }
  .connection-note { grid-column:3; grid-row:2; min-height:0; margin:0; font-size:.65rem; }
  .start-actions { grid-column:3; grid-row:3 / span 2; align-self:end; }
  .start-actions .action-button { min-width:0; min-height:2.5rem; padding:.4rem .45rem; font-size:.72rem; }
  .match-view { width:100%; grid-template-columns:minmax(13rem,.9fr) minmax(0,1.1fr); grid-template-rows:auto auto minmax(0,1fr); gap:.25rem .45rem; }
  .players-row, .match-metrics { grid-column:1; }
  .board-slot { grid-column:2; grid-row:1/-1; height: calc(100dvh - 4rem); align-self: start; overflow: hidden; }
  .board-wrap { width: min(100cqw, 100cqh, calc(100dvh - 4rem)); }
  .match-notice { grid-column:1; }
}

@media (max-width: 350px) {
  .sweeple-header h1 { font-size: 1rem; }
  .quit-link { min-width: 3rem; padding: 0 .55rem; }
  .quit-link span { display: none; }
  .player-heading strong { max-width: 7rem; font-size: .68rem; }
  .progress-copy span { max-width: 12rem; }
}

@media (max-width: 450px) {
  .sweeple-header h1 { font-size: clamp(1rem, 4.7vw, 1.2rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
