/* Tower Duel — a card game where answering a question decides the card you draw (see game.js) */
.view#view-game { max-width: 1040px; margin: 0 auto; }
.gm-top { display: grid; grid-template-columns: 190px minmax(0, 1fr) 190px; gap: 14px; align-items: stretch; margin-top: 12px; }
.gm-side { background: var(--surface); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow-sm); border-top: 5px solid var(--side); }
.gm-side.me { --side: #2f7cf6; }
.gm-side.ai { --side: #e8553d; }
.gm-side.turn { box-shadow: 0 0 0 3px color-mix(in srgb, var(--side) 45%, transparent), var(--shadow-sm); }
.gm-name { font-weight: 750; font-size: 1.0625rem; display: flex; justify-content: space-between; align-items: center; }
.gm-name small { font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #fff; background: var(--side); padding: 1px 8px; border-radius: 999px; opacity: 0; transition: opacity 200ms ease; }
.gm-side.turn .gm-name small { opacity: 1; }
.gm-stat { position: relative; display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; border-bottom: 1px solid var(--separator); font-size: 0.9375rem; }
.gm-stat:last-child { border-bottom: 0; }
.gm-stat b { font-variant-numeric: tabular-nums; font-size: 1.0625rem; }
.gm-stat .sub { display: block; font-size: 0.75rem; color: var(--text-2); }
.gm-stat .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.sw.red { background: #e8553d; } .sw.blue { background: #2f7cf6; } .sw.green { background: #2fa84f; }
.gm-delta {
  position: absolute; right: 34px; top: 2px; font-weight: 800; font-size: 0.9375rem; pointer-events: none;
  animation: gmDelta 1400ms var(--ease-out) forwards;
}
.gm-delta.up { color: var(--green); } .gm-delta.down { color: var(--red); }
@keyframes gmDelta { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; transform: none; } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

/* Arena with the two castles */
.gm-arena {
  position: relative; min-height: 310px; border-radius: 18px; overflow: hidden;
  background: linear-gradient(180deg, #bfe0ff 0%, #e6f3ff 70%, #9fd18a 70%, #86c070 100%);
  box-shadow: var(--shadow-sm);
}
.gm-goal { position: absolute; left: 0; right: 0; bottom: 85%; border-top: 2px dashed rgba(29, 29, 31, 0.3); }
.gm-goal span { position: absolute; left: 50%; transform: translate(-50%, -110%); font-size: 0.6875rem; font-weight: 700; color: rgba(29, 29, 31, 0.55); white-space: nowrap; }
.castle { position: absolute; bottom: 30%; height: 55%; display: flex; align-items: flex-end; gap: 6px; z-index: 1; }
.castle.me { left: 9%; } .castle.ai { right: 9%; }
.castle.ai { flex-direction: row-reverse; }
.tower {
  position: relative; width: 44px; border-radius: 3px 3px 0 0; transition: height 700ms var(--spring);
  background: repeating-linear-gradient(0deg, transparent 0 13px, rgba(0, 0, 0, 0.12) 13px 14px), var(--stone);
}
.castle.me .tower { --stone: #7f9bc4; --roof: #2f7cf6; }
.castle.ai .tower { --stone: #c49c8c; --roof: #e8553d; }
.tower::before {
  content: ""; position: absolute; left: -6px; right: -6px; bottom: 100%; height: 34px;
  background: var(--roof); clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.tower::after { content: ""; position: absolute; left: 15px; top: 14px; width: 14px; height: 18px; border-radius: 7px 7px 0 0; background: rgba(0, 0, 0, 0.35); }
.wall {
  width: 18px; border-radius: 2px 2px 0 0; transition: height 700ms var(--spring);
  background: repeating-linear-gradient(0deg, #8a6d5b 0 8px, #6f5546 8px 9px), #8a6d5b;
}
.castle .num {
  position: absolute; bottom: -24px; font-size: 0.75rem; font-weight: 700; color: #234018; white-space: nowrap;
  left: 0;
}
.castle.ai .num { left: auto; right: 0; }
.gm-played { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 2; text-align: center; pointer-events: none; }
.gm-played .who { font-size: 0.75rem; font-weight: 700; background: rgba(255, 255, 255, 0.85); border-radius: 999px; padding: 2px 10px; display: inline-block; margin-bottom: 6px; }
.gm-played .gcard { width: 124px; min-height: 0; margin: 0 auto; animation: gmPlay 520ms var(--spring); }
.gm-played.discard .gcard { filter: grayscale(0.8); opacity: 0.75; }
@keyframes gmPlay { from { opacity: 0; transform: translateY(40px) scale(0.85); } }

.gm-msg { text-align: center; font-weight: 600; min-height: 1.6em; margin: 14px 0 8px; font-size: 1.0625rem; }
.gm-msg.ai { color: #c23c26; }

/* Cards */
.gm-hand { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; }   /* 6 or 7 cards in a row */
.gcard {
  --c: #2f7cf6; --c2: #1e4fd8; --c3: #0b1d5c; --frame: #d9e2f0;
  position: relative; display: flex; flex-direction: column; text-align: start; padding: 5px; border: 0;
  border-radius: 14px; background: linear-gradient(160deg, #fff, #f3f5fa); overflow: hidden; min-height: 200px;
  box-shadow: 0 0 0 2px var(--frame), 0 4px 12px rgba(30, 40, 90, 0.12);
  transition: transform 160ms var(--ease-out), box-shadow 160ms ease, opacity 160ms ease, filter 160ms ease;
  outline: 0;
}
.gcard.red { --c: #ffb26b; --c2: #e0452a; --c3: #5a0f1c; --frame: #f2c8bd; }
.gcard.blue { --c: #8fd3ff; --c2: #4b5cf0; --c3: #1a0d55; --frame: #c9cff7; }
.gcard.green { --c: #b6f08a; --c2: #1f9d55; --c3: #062f2a; --frame: #bfe5c9; }
.gcard.t3 { --frame: #f0c040; background: linear-gradient(160deg, #fffaf0, #fff0c8); box-shadow: 0 0 0 2px var(--frame), 0 0 14px rgba(240, 192, 64, 0.45), 0 4px 12px rgba(30, 40, 90, 0.12); }
.gcard .gc-art {
  position: relative; height: 82px; border-radius: 10px; display: grid; place-items: center; color: #fff; overflow: hidden;
  background:
    radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--c) 85%, white) 0%, transparent 42%),
    radial-gradient(1px 1px at 18% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 86% 70%, rgba(255, 255, 255, 0.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 30% 80%, rgba(255, 255, 255, 0.7) 50%, transparent 51%),
    linear-gradient(170deg, var(--c2) 0%, var(--c3) 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), inset 0 -10px 18px rgba(0, 0, 0, 0.25);
}
.gcard .gc-art > svg { grid-area: 1 / 1; }
.gcard .gc-ring { width: 74px; height: 74px; color: rgba(255, 255, 255, 0.55); animation: gcSpin 24s linear infinite; }
.gcard .gc-pic {
  width: 44px; height: 44px; stroke-width: 1.7; position: relative;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.9)) drop-shadow(0 0 10px var(--c));
}
.gcard .gc-tw { position: absolute; width: var(--s); height: var(--s); color: #fff; opacity: 0; animation: gcTwinkle 3s ease-in-out infinite; }
@keyframes gcSpin { to { transform: rotate(360deg); } }
@keyframes gcTwinkle { 0%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg); } 50% { opacity: 0.95; transform: scale(1) rotate(45deg); } }
.gcard.t3 .gc-art::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 240, 190, 0.5) 45%, transparent 60%);
  background-size: 250% 100%; animation: gcShine 3.2s ease-in-out infinite;
}
@keyframes gcShine { 0% { background-position: 120% 0; } 60%, 100% { background-position: -60% 0; } }
.gcard .gc-cost {
  position: absolute; top: 5px; left: 5px; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 13px; z-index: 1;
  background: radial-gradient(circle at 35% 30%, #fff, #e8ecf5); color: var(--c2); font-weight: 800; font-size: 0.875rem;
  display: grid; place-items: center; box-shadow: 0 0 0 2px var(--c), 0 1px 4px rgba(0, 0, 0, 0.35);
}
.gcard .gc-again {
  position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border-radius: 50%; z-index: 1;
  background: rgba(255, 255, 255, 0.92); color: var(--c2); font-weight: 800; font-size: 0.9375rem; display: grid; place-items: center;
}
.gcard .gc-head {
  margin: 6px 2px 0; padding: 2px 4px 4px; text-align: center; font-weight: 750; font-size: 0.875rem; line-height: 1.2;
  color: var(--c2); border-bottom: 1px dashed var(--frame);
}
.gcard .gc-text { flex: 1; padding: 6px 6px 2px; font-size: 0.8125rem; line-height: 1.35; color: var(--text); text-align: center; font-weight: 500; }
.gcard .gc-text div + div { margin-top: 2px; }
.gcard .gc-foot { display: flex; justify-content: space-between; align-items: center; padding: 4px 5px 2px; font-size: 0.6875rem; color: var(--text-2); font-weight: 600; }
.gcard .stars { color: #f5a400; letter-spacing: 1px; font-size: 0.8125rem; }
.gcard .stars i { color: #ddd; font-style: normal; }
.gm-hand .gcard { cursor: pointer; }
.gm-hand .gcard:hover:not(.empty) { transform: translateY(-3px); }
.gm-hand .gcard.sel { transform: translateY(-10px); box-shadow: 0 0 0 3px var(--c2), 0 12px 24px rgba(0, 0, 0, 0.2); }
.gm-hand .gcard.poor { filter: grayscale(0.65); opacity: 0.6; }
.gm-hand .gcard.poor.sel { opacity: 0.85; }
.gm-hand .gcard.empty { background: rgba(255, 255, 255, 0.4); box-shadow: inset 0 0 0 2px var(--separator); cursor: default; }
/* Face-down card: the other player can't see your hand before you answer */
.gm-hand .gcard.empty.back {
  background: repeating-linear-gradient(45deg, #4b3f8f 0 8px, #5a4ca6 8px 16px);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.gm-hand .gcard.new { animation: gmDraw 520ms var(--spring); }
@keyframes gmDraw { from { opacity: 0; transform: translateY(-30px) rotate(-4deg) scale(0.9); } }
.gm-hand.wait .gcard { cursor: default; }
.gcard .need { position: absolute; left: 0; right: 0; top: 64px; z-index: 1; text-shadow: 0 0 4px #fff, 0 0 4px #fff; text-align: center; font-size: 0.6875rem; font-weight: 700; color: var(--red); }
.gm-actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.gm-actions .btn { min-width: 150px; }
.gm-help { text-align: center; color: var(--text-3); font-size: 0.75rem; margin-top: 10px; }

/* Question dialog */
dialog.gq { width: min(560px, calc(100vw - 32px)); }
.gq-timer { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); margin: 12px 34px 0 0; }
.gq-timer > div { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, #34c759, #7c5cff); transform-origin: left; }
.gq-timer > span { position: absolute; right: -32px; top: 50%; transform: translateY(-50%); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-2); }
.gq-timer.low > div { background: linear-gradient(90deg, #ff3b30, #ff9f0a); }
.gq-timer.low > span { color: var(--red); }
.gq-timer.stopped { opacity: 0.4; }
.gq .kicker { background: var(--accent-tint); color: var(--accent); }
.gq-prompt { font-size: clamp(1.125rem, 3vw, 1.375rem); font-weight: 650; line-height: 1.3; margin: 10px 4px 0; overflow-wrap: anywhere; }
.gq .map { margin-top: 12px; }
.gq .options { margin-top: 14px; }
.gq-result { margin-top: 14px; display: flex; gap: 14px; align-items: center; background: var(--bg); border-radius: 16px; padding: 12px; }
.gq-result .gcard { width: 130px; flex: 0 0 130px; animation: gmDraw 520ms var(--spring); }
.gq-result .txt { flex: 1; min-width: 0; }
.gq-result.good { background: var(--green-tint); } .gq-result.good h2 { color: var(--green); }
.gq-result.bad { background: var(--red-tint); } .gq-result.bad h2 { color: var(--red); }
.gq-result h2 { font-size: 1.125rem; }
.gq-result p { margin: 4px 0 0; color: var(--text-2); font-size: 0.9375rem; overflow-wrap: anywhere; }
.gq-result p b { color: var(--text); }
.gm-rules { font-size: 0.875rem; color: var(--text-2); margin: 0 4px; padding-left: 18px; }
.gm-rules li + li { margin-top: 4px; }
.badge.game { background: rgba(255, 149, 0, 0.16); color: #c25e00; }

@media (max-width: 760px) {
  .gm-top { grid-template-columns: 1fr 1fr; }
  .gm-arena { grid-column: 1 / -1; grid-row: 1; min-height: 220px; }
  .gm-hand { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gm-side { padding: 10px 12px; }
}
/* Reading text in the question dialog */
.gq .read-text { background: var(--surface-2); margin: 10px 4px 0; max-height: 38vh; }

/* Traits: owned upgrades under the stats, and the Traits & market dialog */
.gm-traits { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.gm-traits:empty { display: none; }
.gm-traits span { font-size: 0.6875rem; font-weight: 700; color: var(--accent); background: var(--accent-tint); border-radius: 999px; padding: 1px 8px; }
.gm-trait-note { color: var(--text-2); margin: 4px 4px 12px; }
.gm-trait { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: 12px; margin-bottom: 8px; }
.gm-trait > div { flex: 1; min-width: 0; }
.gm-trait b { display: block; }
.gm-trait small { display: block; color: var(--text-2); margin-top: 2px; }
.gm-trait .btn { white-space: nowrap; }
.gm-owned { font-weight: 700; color: var(--green-fill, #2a9d4b); white-space: nowrap; }
.gm-mkt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 4px 8px; }
.gm-mkt-row > span { min-width: 110px; font-weight: 600; }
.gm-owned-box { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.gm-owned-box .btn { font-size: 0.8125rem; padding: 4px 10px; min-height: 0; }
