/* Cardwright — a Stoken Games title */
:root {
  --paper: #f3e9d2;
  --paper2: #e9dbbc;
  --ink: #33261a;
  --ink2: #6b5842;
  --wood: #7a5a38;
  --wood2: #5a4128;
  --gold: #e0b23c;
  --red: #b0432e;
  --green: #4c7c4c;
  --sky: #cfe3dd;
  --night: #2b3a4a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Georgia, 'Times New Roman', serif;
  background:
    radial-gradient(1200px 600px at 70% -10%, #fdf6e0 0%, transparent 60%),
    linear-gradient(160deg, #efe2c4 0%, #e2d0a8 100%);
  color: var(--ink);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
#app { height: 100vh; display: flex; flex-direction: column; }

/* ------- top bar ------- */
#topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 16px;
  background: linear-gradient(180deg, var(--wood) 0%, var(--wood2) 100%);
  color: #f5ead0; box-shadow: 0 2px 8px rgba(50,30,10,0.35);
  z-index: 20; flex: 0 0 auto;
}
#topbar .logo { font-size: 20px; font-weight: bold; letter-spacing: 0.5px; text-shadow: 0 1px 0 #3a2a18; }
#topbar .logo small { font-size: 11px; opacity: 0.75; font-weight: normal; margin-left: 6px; }
#topbar .spacer { flex: 1; }
#topbar .chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.25); border: 1px solid rgba(255,240,200,0.25);
  border-radius: 20px; padding: 4px 12px; font-size: 14px;
}
#topbar button {
  background: #8d6a42; color: #f5ead0; border: 1px solid #b99668;
  border-radius: 8px; padding: 5px 12px; font-size: 13px;
}
#topbar button:hover { background: #a07a4c; }

#screen { flex: 1; overflow: auto; position: relative; }

/* ------- generic ------- */
.btn {
  background: linear-gradient(180deg, #8d6a42, #6d4e2c);
  color: #f7edd6; border: 1px solid #b99668; border-radius: 10px;
  padding: 10px 22px; font-size: 16px; box-shadow: 0 2px 5px rgba(50,30,10,0.3);
  transition: transform 0.08s ease, filter 0.15s;
}
.btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; transform: none; }
.btn.primary { background: linear-gradient(180deg, #c8963c, #9c6f1e); border-color: #ecd28c; }
.btn.danger { background: linear-gradient(180deg, #a2503c, #7c3323); border-color: #d29a86; }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
h1, h2, h3 { font-weight: bold; color: var(--ink); }

/* ------- cards ------- */
.card {
  position: relative; width: 176px; flex: 0 0 auto;
  filter: drop-shadow(0 3px 4px rgba(50,30,10,0.35));
  transition: transform 0.15s ease;
  border-radius: 12px;
}
.card .cardsvg { display: block; width: 100%; height: auto; }
.card.sel { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 12px; }
.cardtext { font-family: Georgia, serif; font-size: 12.5px; line-height: 1.28; color: #33261a; padding: 2px 3px; }
.cardtext .fx { margin-bottom: 4px; }
.cardtext .flav { font-style: italic; color: #7a6a50; font-size: 11px; }
.cardtext.big { font-size: 16px; line-height: 1.3; }
.cardtext.big .flav { font-size: 14px; }
.card .count {
  position: absolute; right: -6px; top: -6px; background: var(--night); color: #ffe9a8;
  font-size: 12px; font-weight: bold; border-radius: 12px; padding: 2px 8px;
  border: 1px solid #ffe9a8;
}
.card .newbadge {
  position: absolute; left: -6px; top: -6px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: bold; border-radius: 10px; padding: 2px 7px;
  transform: rotate(-8deg); border: 1px solid #ffd9cc;
}
.card.clickable:hover { transform: translateY(-6px) scale(1.03); }
.card.dim { opacity: 0.45; filter: grayscale(0.6) drop-shadow(0 2px 3px rgba(50,30,10,0.3)); }
.card.unknown .unknownface {
  aspect-ratio: 200 / 280; border-radius: 12px; border: 3px solid var(--rc, #9aa3ad);
  background:
    radial-gradient(circle at 50% 42%, #a97e33 0 20%, transparent 21%),
    repeating-conic-gradient(from 0deg at 50% 42%, #6d4e2c 0 15deg, #7a5a38 15deg 30deg);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: bold; color: #ffe9a8; text-shadow: 0 0 10px rgba(0,0,0,0.5);
  opacity: 0.8;
}
.poolcard.depleted { opacity: 0.4; filter: saturate(0.4); }
.poolcard { cursor: pointer; }

/* ------- title screen ------- */
.title-screen {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  text-align: center; padding: 20px;
}
.title-screen h1 { font-size: 52px; letter-spacing: 1px; text-shadow: 0 2px 0 #fff8e6, 0 4px 10px rgba(90,60,20,0.35); }
.title-screen .sub { font-size: 17px; color: var(--ink2); max-width: 560px; line-height: 1.5; }
.title-screen .studio { margin-top: 26px; font-size: 12px; letter-spacing: 3px; color: #8a744f; text-transform: uppercase; }
.title-cards { display: flex; gap: 10px; margin: 8px 0 4px; }
.title-cards .card { width: 120px; animation: bob 3.2s ease-in-out infinite; }
.title-cards .card:nth-child(2) { animation-delay: 0.4s; }
.title-cards .card:nth-child(3) { animation-delay: 0.8s; }
.title-cards .card:nth-child(4) { animation-delay: 1.2s; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }

/* ------- town map ------- */
.town { height: 100%; display: flex; flex-direction: column; }
.town .mapwrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; min-height: 0; }
.town svg.map { width: min(100%, 1050px); height: 100%; max-height: 640px; }
.mapnode { cursor: pointer; }
.mapnode .plate { transition: transform 0.12s ease, filter 0.12s; transform-box: fill-box; transform-origin: center; }
.mapnode:hover .plate { transform: scale(1.05); filter: brightness(1.08); }
.mapnode.locked { cursor: default; opacity: 0.55; }
.mapnode.locked:hover .plate { transform: none; filter: grayscale(0.4); }
.town .hint { text-align: center; padding: 6px 10px 12px; color: var(--ink2); font-style: italic; }

/* ------- dialogue overlay ------- */
.overlay {
  position: fixed; inset: 0; background: rgba(35,24,12,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  animation: fadein 0.2s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  background: var(--paper); border: 3px solid var(--wood);
  border-radius: 16px; padding: 22px 26px; max-width: 620px; width: calc(100% - 40px);
  box-shadow: 0 12px 40px rgba(30,18,6,0.5);
  animation: pop 0.22s ease;
  max-height: 88vh; overflow: auto;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.dialog .who { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.dialog .who .name { font-size: 20px; font-weight: bold; }
.dialog .who .title { font-size: 13px; color: var(--ink2); font-style: italic; }
.dialog .line { font-size: 16px; line-height: 1.55; margin: 10px 0; }
.dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.rules { font-size: 14.5px; line-height: 1.55; }
.rules h4 {
  margin: 14px 0 6px; font-size: 15px; color: var(--wood2);
  border-bottom: 2px solid var(--paper2); padding-bottom: 3px;
}
.rules h4:first-child { margin-top: 2px; }
.rules ul { margin: 0 0 4px 20px; }
.rules li { margin-bottom: 5px; }
.rchip {
  display: inline-block; background: var(--c, #7a5a38); color: #fff;
  border-radius: 10px; padding: 1px 9px; font-size: 12.5px; font-weight: bold; margin-right: 4px;
}
.setrow { display: flex; align-items: center; gap: 14px; margin: 14px 0; }
.setrow label { flex: 0 0 150px; font-size: 15.5px; color: var(--ink); }
.setrow input[type="range"] { flex: 1; accent-color: var(--gold); cursor: pointer; }
.setrow input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--gold); cursor: pointer; }
.dialog textarea {
  width: 100%; height: 110px; font-family: monospace; font-size: 11px;
  background: #fffbef; border: 2px solid var(--wood); border-radius: 8px; padding: 8px;
}

/* ------- shop ------- */
.shop { padding: 18px; max-width: 980px; margin: 0 auto; }
.shop .keeper { display: flex; gap: 16px; align-items: center; background: var(--paper); border: 2px solid var(--wood); border-radius: 14px; padding: 14px 18px; margin-bottom: 16px; }
.shop .keeper .speech { flex: 1; font-size: 15.5px; line-height: 1.5; font-style: italic; }
.shop .wares { display: flex; gap: 26px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 12px; }
.shop .packwrap { text-align: center; }
.shop .packwrap svg { filter: drop-shadow(0 5px 8px rgba(50,30,10,0.4)); transition: transform 0.15s; }
.shop .packwrap:hover svg { transform: translateY(-4px) rotate(-1.5deg); }
.shop .factionblurb { max-width: 300px; background: var(--paper); border: 2px solid var(--wood); border-radius: 12px; padding: 14px; font-size: 14px; line-height: 1.5; }

/* ------- pack opening ------- */
.packopen { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 20px; }
.packopen .cards { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; perspective: 1000px; }
.flipcard { width: 160px; height: 224px; position: relative; cursor: pointer; }
.flipcard .inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d; transition: transform 0.5s cubic-bezier(0.4, 1.4, 0.6, 1);
}
.flipcard.flipped .inner { transform: rotateY(180deg); }
.flipcard .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 12px; }
.flipcard .back {
  background:
    radial-gradient(circle at 50% 42%, #a97e33 0 20%, transparent 21%),
    repeating-conic-gradient(from 0deg at 50% 42%, #6d4e2c 0 15deg, #7a5a38 15deg 30deg);
  border: 3px solid var(--gold); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.35), 0 4px 8px rgba(40,25,8,0.4);
}
.flipcard .back::after { content: '✦'; font-size: 42px; color: #ffe9a8; text-shadow: 0 0 12px #ffdf80; }
.flipcard .front { transform: rotateY(180deg); }
.flipcard .front .card { width: 100%; }
.flipcard.rare-glow .back { animation: rareglow 1.1s ease-in-out infinite; border-color: #ffe066; }
@keyframes rareglow { 0%,100% { box-shadow: 0 0 10px 2px rgba(255,215,80,0.5), inset 0 0 30px rgba(0,0,0,0.35); } 50% { box-shadow: 0 0 26px 8px rgba(255,215,80,0.9), inset 0 0 30px rgba(0,0,0,0.35); } }
.flipcard.mythic-glow .back { animation: mythglow 0.9s ease-in-out infinite; border-color: #ff9c4a; }
@keyframes mythglow { 0%,100% { box-shadow: 0 0 14px 4px rgba(255,120,50,0.65), inset 0 0 30px rgba(0,0,0,0.35); } 50% { box-shadow: 0 0 34px 12px rgba(255,140,60,1), inset 0 0 30px rgba(0,0,0,0.35); } }
.flipcard.flipped.rare-pop { animation: rarepop 0.5s ease 0.25s; }
@keyframes rarepop { 0% { transform: scale(1); } 40% { transform: scale(1.14) rotate(1.5deg); } 100% { transform: scale(1); } }

/* sparkle burst for mythics */
.spark { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #ffd76a; pointer-events: none; animation: sparkfly 0.8s ease-out forwards; z-index: 5; }
@keyframes sparkfly { from { opacity: 1; transform: translate(0,0) scale(1); } to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); } }

/* ------- binder & deck builder ------- */
.binder { padding: 18px; max-width: 1100px; margin: 0 auto; }
.binder .grid, .builder .grid { display: flex; flex-wrap: wrap; gap: 12px; }
.binder .filters, .builder .filters { display: flex; gap: 8px; margin: 10px 0 16px; flex-wrap: wrap; align-items: center; }
.fbtn {
  border: 2px solid var(--wood); background: var(--paper); color: var(--ink);
  border-radius: 18px; padding: 4px 12px; font-size: 13px;
}
.fbtn.on { background: var(--wood); color: #f5ead0; }
.builder { display: flex; height: 100%; gap: 0; }
.builder .pool { flex: 1; overflow: auto; padding: 16px; }
.builder .deckpane {
  width: 300px; flex: 0 0 auto; background: var(--paper2); border-left: 3px solid var(--wood);
  padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 8px;
}
.builder .deckpane h3 { display: flex; justify-content: space-between; align-items: center; }
.deckrow {
  display: flex; align-items: center; gap: 8px; background: #fffbef; border: 1.5px solid var(--wood);
  border-radius: 8px; padding: 5px 8px; cursor: pointer; font-size: 13.5px;
  transition: transform 0.1s;
}
.deckrow:hover { transform: translateX(-3px); background: #fff3d6; }
.deckrow .cost {
  width: 22px; height: 22px; border-radius: 50%; background: var(--night); color: #ffe9a8;
  font-size: 12px; font-weight: bold; display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.deckrow .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deckrow .pt { font-size: 12px; color: var(--ink2); }
.curvebar { display: flex; gap: 3px; align-items: flex-end; height: 46px; margin: 6px 0; }
.curvebar .bar { flex: 1; background: var(--wood); border-radius: 3px 3px 0 0; min-height: 3px; position: relative; }
.curvebar .bar span { position: absolute; top: -16px; width: 100%; text-align: center; font-size: 10px; color: var(--ink2); }
.curvebar .bar em { position: absolute; bottom: -16px; width: 100%; text-align: center; font-size: 10px; font-style: normal; color: var(--ink2); }

/* ------- duel board ------- */
.duel { height: 100%; display: flex; flex-direction: column; background:
  radial-gradient(900px 400px at 50% 46%, #e6d5ae 0%, transparent 70%),
  linear-gradient(180deg, #d9c69c 0%, #cdb88a 100%); }
.duel .oppbar, .duel .mybar {
  display: flex; align-items: center; gap: 12px; padding: 6px 16px; flex: 0 0 auto;
}
.duel .oppbar { background: rgba(60,40,20,0.18); }
.duel .mybar { background: rgba(60,40,20,0.12); }
.lifeorb {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d76a52, #8c2a1c);
  color: #fff; font-size: 18px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #ffd9cc; box-shadow: 0 2px 6px rgba(60,20,8,0.4);
  transition: transform 0.15s;
}
.lifeorb.pulse { animation: lifepulse 0.4s ease; }
@keyframes lifepulse { 0% { transform: scale(1); } 40% { transform: scale(1.25); background: #e33; } 100% { transform: scale(1); } }
.manarow { display: flex; gap: 4px; }
.manaorb { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #7fb6de, #2b5a80); border: 1.5px solid #cfe6f5; }
.manaorb.spent { background: #9aa3ad44; border-color: #9aa3ad66; }
.duel .pname { font-weight: bold; font-size: 15px; }
.duel .deckcount { font-size: 12.5px; color: #4a3a26; background: rgba(255,250,235,0.6); border-radius: 10px; padding: 2px 9px; }
.enchantrow { display: flex; gap: 6px; }
.enchip {
  font-size: 11.5px; background: #efe0ba; border: 1.5px solid var(--gold); border-radius: 10px;
  padding: 2px 8px; cursor: help;
}
.duel .field { flex: 1; display: flex; flex-direction: column; justify-content: space-around; min-height: 0; padding: 4px 12px; }
.duel .boardrow { display: flex; gap: 10px; justify-content: center; align-items: center; min-height: 96px; flex-wrap: wrap; }
.duel .centerline { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 2px; }
.duel .phasemsg { font-size: 15px; font-style: italic; color: #5a4128; text-align: center; min-height: 22px; }

.creature {
  position: relative; width: 92px; height: 84px; cursor: default;
  transition: transform 0.15s ease, box-shadow 0.15s;
}
.creature .cbody {
  width: 100%; height: 100%; border-radius: 12px;
  background: linear-gradient(160deg, var(--fc), var(--fc2));
  border: 2px solid #f7f1e3; box-shadow: 0 3px 6px rgba(50,30,10,0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  padding: 4px 4px 10px;
}
.creature .cname { font-size: 10.5px; color: #fff; text-align: center; line-height: 1.1; font-weight: bold; text-shadow: 0 1px 2px rgba(0,0,0,0.45); }
.creature .kwrow { display: flex; gap: 2px; min-height: 14px; }
.kwchip { font-size: 9px; background: rgba(0,0,0,0.35); color: #ffe9a8; border-radius: 8px; padding: 0 4px; }
.creature .stat {
  position: absolute; bottom: -8px; width: 24px; height: 24px; border-radius: 50%;
  font-size: 12.5px; font-weight: bold; color: #fff; display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.creature .pw { left: -6px; background: #b0642e; }
.creature .hp { right: -6px; background: #4c7c4c; }
.creature .hp.hurt { background: #a2503c; }
.creature.canatk { cursor: pointer; }
.creature.canatk:hover { transform: translateY(-4px); }
.creature.attacking { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 12px; transform: translateY(-8px); }
.creature.enemyattacker { outline: 3px solid var(--red); outline-offset: 2px; border-radius: 12px; }
.creature.blocker { outline: 3px solid #2b6a9c; outline-offset: 2px; border-radius: 12px; }
.creature.targetable { cursor: crosshair; animation: targetglow 0.9s ease-in-out infinite; }
@keyframes targetglow { 0%,100% { box-shadow: 0 0 4px 2px rgba(224,178,60,0.6); } 50% { box-shadow: 0 0 14px 6px rgba(224,178,60,1); } }
.creature.dying { animation: die 0.45s ease forwards; }
@keyframes die { to { opacity: 0; transform: scale(0.5) rotate(10deg); } }
.creature.entering { animation: enter 0.3s ease; }
@keyframes enter { from { opacity: 0; transform: scale(0.6) translateY(10px); } }

/* attack smack: wind up, dash to the target (--sx/--sy), bounce home */
.creature.striking { z-index: 40; animation: smack 0.57s cubic-bezier(0.3, 0.1, 0.4, 1) both; }
@keyframes smack {
  0%   { transform: translate(0, 0); }
  22%  { transform: translate(calc(var(--sx) * -0.14), calc(var(--sy) * -0.14)) scale(1.05) rotate(-2deg); }
  42%  { transform: translate(var(--sx), var(--sy)) scale(1.12); }
  56%  { transform: translate(calc(var(--sx) * 0.92), calc(var(--sy) * 0.92)) scale(1.06); }
  100% { transform: translate(0, 0); }
}
.creature.smacked, .lifeorb.smacked { animation: smackrecv 0.38s ease; }
/* fast mode: same choreography, half the clock */
.duel.fast .creature.striking { animation-duration: 0.26s; }
.duel.fast .creature.smacked, .duel.fast .lifeorb.smacked { animation-duration: 0.2s; }
.duel.fast .creature.dying { animation-duration: 0.22s; }
@keyframes smackrecv {
  0%   { transform: translate(0, 0); filter: none; }
  30%  { transform: translate(0, var(--knock, 10px)) scale(0.93); filter: brightness(1.7) saturate(1.3); }
  100% { transform: translate(0, 0); filter: none; }
}

.dmgfloat {
  position: fixed; z-index: 60; font-size: 22px; font-weight: bold; color: #d33; pointer-events: none;
  text-shadow: 0 1px 0 #fff, 0 2px 6px rgba(0,0,0,0.3);
  animation: dmgfloat 0.9s ease-out forwards;
}
.dmgfloat.healfloat { color: #3a8a3a; }
@keyframes dmgfloat { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-40px); } }

.duel .handwrap { flex: 0 0 auto; padding: 4px 10px 10px; }
.duel .handrow { display: flex; gap: 8px; justify-content: center; align-items: flex-end; min-height: 205px; flex-wrap: wrap; }
.duel .handrow .card { width: 146px; transition: transform 0.15s ease, filter 0.15s; }
.duel .handrow .card.playable { cursor: pointer; }
.duel .handrow .card.playable:hover { transform: translateY(-20px) scale(1.25); z-index: 10; }
.duel .handrow .card.unplayable { opacity: 0.62; filter: saturate(0.5); }
.duel .handrow .card.pendingplay { outline: 3px solid var(--gold); outline-offset: 2px; }
.duel .actionbar { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 4px 0 2px; min-height: 46px; }
.duel .oppinfo { display: flex; align-items: center; gap: 10px; }
.duellog {
  position: absolute; right: 10px; top: 60px; width: 230px; max-height: 40vh; overflow: auto;
  background: rgba(255,250,235,0.82); border: 2px solid var(--wood); border-radius: 10px;
  font-size: 12px; padding: 8px 10px; line-height: 1.45; z-index: 15;
}
.duellog div { margin-bottom: 3px; }
.duellog .recent { font-weight: bold; }

/* ------- victory ------- */
.victory { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 24px; position: relative; overflow: hidden; }
.victory h1 { font-size: 44px; text-shadow: 0 2px 0 #fff8e6, 0 5px 14px rgba(150,110,30,0.5); }
.victory .wrenline { max-width: 640px; font-size: 18px; line-height: 1.6; font-style: italic; background: var(--paper); border: 2px solid var(--gold); border-radius: 14px; padding: 18px 22px; }
.victory .stats { display: flex; gap: 22px; font-size: 15px; color: var(--ink2); flex-wrap: wrap; justify-content: center; }
.confetti { position: absolute; width: 10px; height: 14px; top: -20px; animation: confall linear forwards; z-index: 1; }
@keyframes confall { to { transform: translateY(110vh) rotate(720deg); } }

/* ------- spell flight & combat forecast ------- */
.spellfly {
  position: fixed; z-index: 75; width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
  border: 2px solid #fff8ee; box-shadow: 0 0 18px 4px rgba(255,230,150,0.55), 0 4px 10px rgba(40,24,8,0.4);
}
#forecast {
  position: fixed; z-index: 85; display: none; pointer-events: none;
  background: linear-gradient(180deg, rgba(70,50,30,0.95), rgba(45,32,18,0.95));
  color: #ffe9a8; font-size: 13.5px; font-family: Georgia, serif;
  padding: 7px 14px; border-radius: 10px; border: 1.5px solid var(--gold);
  box-shadow: 0 4px 14px rgba(30,18,6,0.45); max-width: 380px; text-align: center;
}
@media (min-width: 1500px) { #forecast { font-size: 15.5px; } }

/* ------- turn banner & shake ------- */
.turnbanner {
  position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%);
  z-index: 70; pointer-events: none;
  font-size: 34px; font-weight: bold; color: #f7edd6;
  background: linear-gradient(180deg, rgba(90,65,40,0.92), rgba(60,42,24,0.92));
  border: 2px solid var(--gold); border-radius: 14px; padding: 12px 38px;
  box-shadow: 0 8px 28px rgba(30,18,6,0.5);
  animation: bannerpop 1.15s ease forwards;
}
@keyframes bannerpop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  22% { transform: translate(-50%, -50%) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(1); }
}
.duel.shake { animation: boardshake 0.35s ease; }
@keyframes boardshake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-4px, 2px); }
  80% { transform: translate(3px, -1px); }
}

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

/* ------- big hover preview ------- */
#cardpreview {
  position: fixed; z-index: 90; width: 340px; display: none; pointer-events: none;
  filter: drop-shadow(0 10px 28px rgba(40,24,8,0.55));
  animation: previewin 0.12s ease;
}
#cardpreview .card { width: 340px; }
#cardpreview .card:hover { transform: none; }
@keyframes previewin { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }

/* ------- reward toast ------- */
.rewardbox { display: flex; gap: 18px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.rewardbox .coinreward { font-size: 22px; font-weight: bold; display: flex; align-items: center; gap: 8px; }

/* ------- scrollbars (webkit) ------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #a98d62; border-radius: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.06); }

/* ------- large screens: scale the table up ------- */
@media (min-width: 1500px) {
  .card { width: 215px; }
  .duel .handrow .card { width: 200px; }
  .duel .handrow { min-height: 282px; }
  .duel .boardrow { min-height: 130px; }
  .creature { width: 120px; height: 108px; }
  .creature .cbody svg { width: 42px; height: 42px; }
  .creature .cname { font-size: 13px; }
  .creature .stat { width: 29px; height: 29px; font-size: 15px; bottom: -9px; }
  .kwchip { font-size: 11px; }
  .lifeorb { width: 58px; height: 58px; font-size: 23px; }
  .manaorb { width: 20px; height: 20px; }
  .duel .pname { font-size: 18px; }
  .deckcount { font-size: 14.5px; }
  .enchip { font-size: 13.5px; }
  .duel .phasemsg { font-size: 19px; }
  .duellog { width: 290px; font-size: 14px; }
  #cardpreview, #cardpreview .card { width: 420px; }
  .dialog { max-width: 740px; }
  .btn { font-size: 17px; }
}
@media (min-width: 2100px) {
  .card { width: 250px; }
  .duel .handrow .card { width: 235px; }
  .duel .handrow { min-height: 330px; }
  .duel .boardrow { min-height: 152px; }
  .creature { width: 140px; height: 126px; }
  .creature .cbody svg { width: 50px; height: 50px; }
  .creature .cname { font-size: 14.5px; }
  .creature .stat { width: 33px; height: 33px; font-size: 17px; bottom: -10px; }
  .lifeorb { width: 66px; height: 66px; font-size: 26px; }
  .duel .phasemsg { font-size: 21px; }
  .duellog { width: 330px; font-size: 15px; }
  #cardpreview, #cardpreview .card { width: 490px; }
  .dialog { max-width: 820px; }
}

@media (max-width: 900px) {
  .builder { flex-direction: column; }
  .builder .deckpane { width: 100%; border-left: none; border-top: 3px solid var(--wood); }
  .duellog { display: none; }
  .card { width: 132px; }
}
