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

:root {
  --wood: #8a5a2b;
  --wood-dark: #5a3515;
  --cream: #fff6e0;
  --grass: #8fcf5f;
  --grass-dark: #5a9a3a;
  --gold: #ffc93c;
}

body {
  font-family: 'Trebuchet MS', Verdana, sans-serif;
  background: #6fae4a repeating-linear-gradient(45deg, #6fae4a 0 20px, #68a545 20px 40px);
  color: var(--wood-dark);
  height: 100vh;
  display: flex;
  justify-content: center;
  /* GUI text is not selectable with the mouse (game UI, not a document) */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

button { font-family: inherit; cursor: pointer; border: none; }
.hidden { display: none !important; }

.icon { display: inline-block; width: 28px; height: 28px; }
.icon svg { width: 100%; height: 100%; display: block; }

#app {
  position: relative;
  width: 100%;
  max-width: 640px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f3e3bd;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  background: var(--wood);
  border-bottom: 5px solid var(--wood-dark);
  color: var(--cream);
}
.top-bar h1 { font-size: 26px; letter-spacing: 1px; text-shadow: 2px 2px 0 var(--wood-dark); }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { color: var(--gold); width: 32px; height: 32px; }
.gold-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--wood-dark); border-radius: 16px; padding: 4px 14px 4px 6px;
  font-size: 20px; font-weight: bold;
}
.gold-pill .icon { width: 26px; height: 26px; }
.pills { display: flex; align-items: center; gap: 8px; }
.sound-btn { font-size: 20px; padding: 4px 12px; color: var(--cream); transition: transform 0.1s; }
.sound-btn:hover { transform: scale(1.08); }
.sound-btn.off { opacity: 0.55; filter: grayscale(0.7); }

/* ---------- Pages ---------- */
#content { flex: 1; overflow-y: auto; padding: 16px; }
.tab-page { display: none; }
.tab-page.active { display: block; }

.page-title { text-align: center; margin-bottom: 14px; font-size: 24px; }

.empty-page { text-align: center; padding-top: 80px; }
.empty-page h2 { font-size: 28px; margin: 10px 0 6px; }
.big-icon { width: 110px; height: 110px; }

.big-btn {
  display: block;
  margin: 18px auto 0;
  padding: 14px 50px;
  font-size: 26px;
  font-weight: bold;
  color: var(--cream);
  background: linear-gradient(#ffb03a, #e8791f);
  border: 4px solid var(--wood-dark);
  border-radius: 18px;
  box-shadow: 0 6px 0 var(--wood-dark);
  text-shadow: 2px 2px 0 var(--wood-dark);
  transition: transform 0.1s;
}
.big-btn:hover { transform: translateY(-2px); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--wood-dark); }

/* Lobby arena card */
.arena-card {
  text-align: center;
  background: var(--cream);
  border: 4px solid var(--wood-dark);
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 6px 0 var(--wood-dark);
}

/* Battle lobby fits the screen like a mobile game: no scrolling, the arena
   preview shrinks/grows into the leftover space */
#content { min-height: 0; }
#page-battle.active { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
#page-battle .arena-card {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  padding: 8px;
}
#page-battle .arena-preview-wrap { flex: 1 1 auto; min-height: 0; width: auto; align-self: stretch; display: flex; justify-content: center; }
#page-battle #arena-preview { height: 100%; width: auto; max-width: 100%; }
#page-battle .arena-card h2 { font-size: 22px; margin-top: 2px; }
#page-battle .arena-hint { font-size: 11px; }
#page-battle .arena-nav { margin-bottom: 4px; }
#page-battle .arena-progress { margin: 2px auto 0; }
#page-battle #btn-fight { margin-top: 8px; padding: 10px 40px; font-size: 22px; flex-shrink: 0; }
#page-battle .chest-title { margin: 8px 0 6px; font-size: 18px; flex-shrink: 0; }
#page-battle #chest-slots { flex-shrink: 0; }
#page-battle .chest-slot { min-height: 84px; }
#page-battle .chest-icon { width: 38px; height: 38px; }

/* Slim top row inside the arena card: trophy-road progress + quest button */
.top-minirow { display: flex; gap: 8px; margin-bottom: 6px; }
.mini-road {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 4px 10px;
  background: linear-gradient(#6cc04a, #3f9a2a);
  border: 3px solid var(--wood-dark); border-radius: 12px;
  box-shadow: 0 3px 0 var(--wood-dark);
  color: var(--cream); font-size: 14px; font-weight: bold;
  text-shadow: 1px 1px 0 var(--wood-dark);
}
.mini-road .icon { width: 24px; height: 24px; flex-shrink: 0; }
.mini-road .road-badge { font-size: 11px; padding: 2px 8px; }
.road-minicol { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#road-label { font-size: 13px; line-height: 1; }
.road-minibar {
  display: block; height: 8px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 246, 224, 0.7); border-radius: 5px;
  overflow: hidden;
}
#road-fill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(#ffe07a, #e8a51f);
  border-radius: 4px;
  transition: width 0.4s ease-out;
}
.mini-quest {
  position: relative;
  width: 44px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(#8fd0ea, #3b82c4);
  border: 3px solid var(--wood-dark); border-radius: 12px;
  box-shadow: 0 3px 0 var(--wood-dark);
  color: var(--cream);
}
.mini-quest .icon { width: 26px; height: 26px; }
.mini-quest .road-badge {
  position: absolute; top: -10px; right: -10px;
  font-size: 11px; padding: 2px 8px;
}
.arena-label {
  display: inline-block;
  background: var(--grass-dark);
  color: var(--cream);
  padding: 4px 14px;
  border-radius: 12px;
  font-weight: bold;
  margin-bottom: 8px;
}
#arena-preview {
  display: block;
  margin: 0 auto;
  height: 42vh;
  border: 4px solid var(--wood-dark);
  border-radius: 12px;
}
.arena-card h2 { font-size: 30px; margin-top: 6px; }

/* Deck builder: 3-column card grid */
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; margin-bottom: 22px; }
.card-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 6px;
  background: var(--cream);
  border: 4px solid;
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--wood-dark);
  color: var(--wood-dark);
  transition: transform 0.1s;
}
.card-tile:hover { transform: translateY(-2px); }
.card-tile canvas { width: 64px; height: 64px; }
.tile-name { font-weight: bold; font-size: 15px; }
.tile-level { font-size: 12px; }
.tile-bar {
  position: relative; width: 100%; height: 16px; margin-top: 4px;
  background: #d9c59a; border-radius: 8px; overflow: hidden;
}
.tile-bar div { height: 100%; background: #7cc4f0; }
.tile-bar.ready div { background: #5cc24a; }
.tile-bar span { position: absolute; inset: 0; font-size: 11px; font-weight: bold; line-height: 16px; text-align: center; }
.card-grid.swapping .card-tile { outline: 3px dashed var(--gold); outline-offset: 2px; }

/* The deck: a wooden board with 8 sunken slots */
#deck-grid {
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  background: #b98a52;
  border: 4px solid var(--wood-dark);
  border-radius: 16px;
  box-shadow: inset 0 4px 0 rgba(0, 0, 0, 0.2);
}
.deck-slot {
  display: flex;
  min-height: 150px;
  padding: 6px;
  background: rgba(60, 35, 12, 0.35);
  border-radius: 12px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.4);
}
.deck-slot .card-tile { flex: 1; }
.deck-slot-empty { margin: auto; color: var(--cream); font-weight: bold; opacity: 0.7; }

.swap-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 12px; padding: 8px 12px;
  background: var(--gold); border: 3px solid var(--wood-dark); border-radius: 12px; font-weight: bold;
}
.swap-banner button { padding: 4px 12px; font-weight: bold; border-radius: 8px; background: var(--cream); border: 2px solid var(--wood-dark); }

/* Card details popup */
.modal {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(30, 20, 5, 0.55);
}
.modal-box {
  position: relative;
  width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto;
  padding: 16px;
  background: var(--cream);
  border: 5px solid var(--wood-dark);
  border-radius: 20px;
  box-shadow: 0 8px 0 var(--wood-dark);
  text-align: center;
}
.modal-close { position: absolute; top: 4px; right: 12px; background: none; font-size: 30px; font-weight: bold; color: var(--wood-dark); }
.modal-head { display: flex; align-items: center; justify-content: center; gap: 10px; }
.modal-head h3 { font-size: 26px; }
.rarity-chip { color: #fff; padding: 2px 10px; border-radius: 10px; font-size: 13px; font-weight: bold; }
.modal-sub { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 4px 0 10px; font-weight: bold; }
.modal-sub .icon { width: 20px; height: 20px; }
.preview { display: block; width: 100%; aspect-ratio: 260 / 110; border: 3px solid var(--wood-dark); border-radius: 12px; }
.desc { margin: 10px 0; font-size: 15px; }
.stats { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; text-align: left; }
.stats li {
  display: flex; justify-content: space-between; gap: 6px;
  background: #f0dca8; border-radius: 8px; padding: 4px 8px; font-size: 13px;
}
.upgrade-need { margin-top: 10px; font-size: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.action-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 10px;
  font-size: 17px; font-weight: bold;
  color: var(--cream);
  background: linear-gradient(#6cc04a, #3f9a2a);
  border: 3px solid var(--wood-dark);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--wood-dark);
  text-shadow: 1px 1px 0 var(--wood-dark);
}
.action-btn.use { background: linear-gradient(#ffb03a, #e8791f); }
.action-btn:disabled { filter: grayscale(1); opacity: 0.6; cursor: default; }
.action-btn .icon { width: 22px; height: 22px; }
.in-deck { flex: 1; font-weight: bold; }

/* Lobby chests */
.chest-title { text-align: center; margin: 22px 0 10px; font-size: 22px; }
.chest-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chest-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 108px; padding: 6px 4px;
  background: #e6d3a6;
  border: 3px solid var(--wood-dark);
  border-radius: 12px;
  color: var(--wood-dark);
  cursor: default;
}
.chest-slot.empty { background: rgba(90, 53, 21, 0.12); border-style: dashed; }
.chest-slot.ready { background: #fff1b8; border-color: #e8791f; cursor: pointer; box-shadow: 0 0 12px #ffc93c; }
.chest-icon { width: 48px; height: 48px; }
.chest-name { font-size: 11px; font-weight: bold; }
.chest-time { font-size: 13px; font-weight: bold; }

/* Chest rewards popup */
.chest-modal-title { font-size: 26px; }
.chest-big { width: 110px; height: 110px; margin: 6px auto; display: block; }
.reward-gold { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 26px; font-weight: bold; }
.reward-gold .icon { width: 32px; height: 32px; }
.reward-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }
.reward-card {
  display: flex; flex-direction: column; align-items: center;
  width: 90px; padding: 6px;
  background: #fff8e6; border: 3px solid; border-radius: 12px;
}
.reward-card canvas { width: 56px; height: 56px; }
.reward-card span { font-size: 13px; font-weight: bold; }
.reward-card b { font-size: 18px; color: #3f9a2a; }

/* ---------- Tab bar ---------- */
.tab-bar {
  display: flex;
  background: var(--wood);
  border-top: 5px solid var(--wood-dark);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 10px;
  background: transparent;
  color: var(--cream);
  font-weight: bold;
  font-size: 13px;
  border-right: 2px solid var(--wood-dark);
  opacity: 0.8;
}
.tab:last-child { border-right: none; }
.tab .icon { width: 34px; height: 34px; }
.tab.active { background: #b27a3f; box-shadow: inset 0 4px 0 var(--gold); opacity: 1; }

/* ---------- Customize (Díszek) ---------- */
.custom-hint { text-align: center; font-size: 14px; margin: 6px 0 10px; opacity: 0.85; }
.emote-deck {
  display: flex; gap: 10px; justify-content: center;
  background: var(--wood); border: 4px solid var(--wood-dark); border-radius: 16px;
  padding: 12px; margin-bottom: 6px;
}
.emote-slot {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--cream); border: 3px solid var(--wood-dark); border-radius: 12px;
  padding: 6px 6px 4px; font-size: 12px; font-weight: bold; color: var(--wood-dark);
  box-shadow: 0 3px 0 var(--wood-dark); transition: transform 0.1s;
}
.emote-slot canvas { width: 52px; height: 52px; }
.emote-slot.selected { transform: translateY(-6px); background: #fff1b8; border-color: #e8791f; }
.emote-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.emote-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--cream); border: 3px solid var(--wood-dark); border-radius: 12px;
  padding: 8px 4px 6px;
}
.emote-tile canvas { width: 60px; height: 60px; }
.emote-tile .emote-say { font-size: 12px; font-style: italic; opacity: 0.85; }
.emote-tile.locked { filter: grayscale(0.85) brightness(0.92); }
.emote-tile.locked .tile-lock { position: absolute; top: 4px; right: 4px; }
.emote-tile.locked .tile-lock .icon { width: 22px; height: 22px; }
.emote-tile.indeck { border-color: #3f9a2a; box-shadow: 0 0 0 2px #3f9a2a inset; }
.emote-indeck {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  background: #3f9a2a; color: #fff; font-size: 10px; font-weight: bold;
  padding: 1px 8px; border-radius: 8px; white-space: nowrap;
}
.reward-pin { border-color: var(--gold) !important; box-shadow: 0 0 12px rgba(255, 201, 60, 0.7); }

/* ---------- Battle emote bubbles + picker ---------- */
.canvas-wrap { position: relative; }
#btn-emote {
  position: absolute; right: 10px; bottom: 10px; z-index: 16;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--cream); border: 3px solid var(--wood-dark);
  box-shadow: 0 4px 0 var(--wood-dark);
}
#btn-emote .icon { width: 30px; height: 30px; color: var(--wood-dark); }
#btn-emote:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--wood-dark); }
#emote-picker {
  position: absolute; right: 70px; bottom: 10px; z-index: 16;
  display: flex; gap: 8px;
  background: rgba(40, 25, 10, 0.85); border-radius: 16px; padding: 8px;
}
.emote-pick { background: transparent; padding: 0; transition: transform 0.1s; }
.emote-pick canvas { width: 48px; height: 48px; display: block; }
.emote-pick:hover { transform: scale(1.12); }
.emote-bubble {
  position: absolute; z-index: 15;
  display: flex; align-items: center; gap: 6px;
  background: var(--cream); border: 3px solid var(--wood-dark); border-radius: 24px;
  padding: 4px 12px 4px 4px; font-weight: bold; font-size: 16px; color: var(--wood-dark);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  animation: bubblepop 0.35s ease-out; max-width: 80%;
}
.emote-bubble canvas { width: 46px; height: 46px; }
.emote-bubble.enemy { top: 9%; left: 12px; }
.emote-bubble.player { bottom: 9%; right: 12px; }
@keyframes bubblepop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Tap-to-open chests ---------- */
.chest-slot.ready { animation: chestglow 1.6s ease-in-out infinite; }
@keyframes chestglow {
  50% { box-shadow: 0 0 20px #ffc93c; transform: scale(1.04); }
}
.tap-chest {
  background: transparent; padding: 0; display: block; margin: 0 auto;
  transition: transform 0.1s;
}
.tap-chest .chest-big { width: 130px; height: 130px; }
.tap-chest.shake { animation: chestshake 0.3s; }
@keyframes chestshake {
  20% { transform: rotate(-8deg) scale(1.05); }
  45% { transform: rotate(7deg) scale(1.08); }
  70% { transform: rotate(-4deg) scale(1.05); }
  100% { transform: rotate(0) scale(1); }
}
.tap-chest.upgraded { animation: upgradeGlow 1.1s ease-in-out; }
@keyframes upgradeGlow {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(1.25); filter: brightness(1.8) drop-shadow(0 0 22px #ffc93c); }
  100% { transform: scale(1.1); filter: brightness(1.2) drop-shadow(0 0 12px #ffc93c); }
}
.tap-chest.burst { animation: chestburst 0.6s ease-in; }
@keyframes chestburst {
  30% { transform: scale(1.2); filter: brightness(2); }
  100% { transform: scale(1.6); filter: brightness(3); opacity: 0; }
}
.tap-dots { display: flex; gap: 8px; justify-content: center; margin: 10px 0 4px; }
.tap-dots i {
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(90, 53, 21, 0.2); border: 2px solid var(--wood-dark);
}
.tap-dots i.on { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.tap-cancel {
  display: block; margin: 12px auto 0; padding: 8px 26px;
  font-size: 15px; font-weight: bold; color: var(--wood-dark);
  background: transparent; border: 2px solid var(--wood-dark); border-radius: 12px;
}
.reward-cards > div { animation: rewardpop 0.4s backwards; }
@keyframes rewardpop {
  0% { transform: scale(0.3) translateY(20px); opacity: 0; }
  70% { transform: scale(1.1) translateY(-3px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
/* New unlocks shine in their rarity color (green/blue/purple/gold) */
.reward-card.new-one { position: relative; }
.reward-card.new-rare { box-shadow: 0 0 14px #5cc24a; }
.reward-card.new-superrare { box-shadow: 0 0 14px #3fa7f5; }
.reward-card.new-epic {
  box-shadow: 0 0 20px #a55ee0;
  animation: rewardpop 0.4s backwards, epicpulse 1.2s ease-in-out 2;
}
.reward-card.new-legendary {
  box-shadow: 0 0 28px #ffc93c;
  border-width: 4px;
  animation: rewardpop 0.45s backwards, legpulse 1s ease-in-out 3;
}
@keyframes epicpulse { 50% { transform: scale(1.08); filter: brightness(1.4); } }
@keyframes legpulse { 50% { transform: scale(1.15); filter: brightness(1.9); } }
/* Full-screen gold flash for legendary unlocks */
.legend-flash {
  position: fixed; inset: 0; z-index: 99; pointer-events: none;
  background: radial-gradient(circle, rgba(255,220,100,0.9), rgba(255,180,40,0.3) 60%, transparent 75%);
  animation: legflash 1.4s ease-out;
}
@keyframes legflash { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
/* Locked card modal: everything grey, but the preview loop keeps playing */
#card-modal .modal-box.locked { filter: grayscale(1); }
#card-modal .modal-box.levelup { animation: levelup 0.7s; }
@keyframes levelup {
  0% { filter: brightness(1); transform: scale(1); }
  35% { filter: brightness(1.7) drop-shadow(0 0 18px #ffc93c); transform: scale(1.04); }
  100% { filter: brightness(1); transform: scale(1); }
}

/* ---------- Trophy road ---------- */
.road-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; margin-top: 12px; padding: 10px 14px;
  background: linear-gradient(#6cc04a, #3f9a2a);
  border: 4px solid var(--wood-dark); border-radius: 16px;
  box-shadow: 0 4px 0 var(--wood-dark);
  color: var(--cream); text-align: left;
}
.road-btn .icon { width: 40px; height: 40px; flex-shrink: 0; }
.road-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.road-text b { font-size: 18px; text-shadow: 1px 1px 0 var(--wood-dark); }
.road-text span { font-size: 13px; opacity: 0.95; }
.road-badge {
  background: #e05a47; border: 2px solid #fff6e0; border-radius: 12px;
  font-size: 13px; font-weight: bold; padding: 4px 10px; white-space: nowrap;
  animation: roadpulse 1.1s ease-in-out infinite;
}
@keyframes roadpulse { 50% { transform: scale(1.1); } }
.road-box { max-height: 84vh; overflow-y: auto; }
.road-track {
  display: flex; gap: 10px; overflow-x: auto; padding: 18px 6px 10px;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  user-select: none;
}
.road-track.dragging { cursor: grabbing; }
.road-node {
  position: relative; flex: 0 0 108px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #fff8e6; border: 3px solid var(--wood-dark); border-radius: 14px;
  padding: 10px 6px;
}
.road-node:nth-child(even) { margin-top: 26px; }
.road-circle {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--cream); border: 3px solid var(--wood-dark);
  display: flex; align-items: center; justify-content: center;
}
.road-circle .icon { width: 34px; height: 34px; }
.road-pin { width: 52px; height: 52px; }
.road-cards { display: flex; gap: 4px; justify-content: center; }
.road-cards .road-pin { width: 44px; height: 44px; }
.road-t { font-size: 15px; }
.road-rew { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: bold; flex-direction: column; }
.road-rew .icon { width: 26px; height: 26px; }
.road-node.claimed { opacity: 0.75; }
.road-node.claimed .road-circle { background: #bfe3a8; }
.road-check { color: #2f6a1d; }
.road-node.claimable { border-color: #e8791f; box-shadow: 0 0 14px #ffc93c; animation: roadpulse 1.2s ease-in-out infinite; }
.road-claim {
  margin-top: 4px; padding: 6px 10px;
  font-size: 13px; font-weight: bold; color: var(--cream);
  background: linear-gradient(#ffb03a, #e8791f);
  border: 2px solid var(--wood-dark); border-radius: 10px;
  box-shadow: 0 3px 0 var(--wood-dark);
}
.road-node.locked { filter: grayscale(0.7); }
.road-lock { width: 22px; height: 22px; opacity: 0.7; }
.emote-indeck.road { background: #c98512; }

/* ---------- Cloud-first boot veil + net status ---------- */
#boot-veil {
  position: absolute; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(30, 20, 5, 0.55);
  color: var(--cream); font-size: 22px; font-weight: bold;
  text-shadow: 2px 2px 0 var(--wood-dark);
}
#boot-veil span { animation: veilpulse 1s ease-in-out infinite; }
@keyframes veilpulse { 50% { opacity: 0.55; } }
#net-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #5cc24a; border: 2px solid var(--wood-dark);
  align-self: center; flex-shrink: 0;
}
#net-dot.off { background: #8a8a8a; }

/* ---------- Account ---------- */
#btn-account .icon { width: 26px; height: 26px; }
#btn-account.off { opacity: 0.55; }
.account-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.account-form input {
  padding: 10px 12px; font-size: 16px; font-family: inherit;
  border: 3px solid var(--wood-dark); border-radius: 12px;
  background: #fffdf4; color: var(--wood-dark);
}
.account-err { color: #c0392b; font-weight: bold; }
.account-transfer { margin-top: 10px; border-top: 2px dashed var(--wood-dark); padding-top: 8px; }
.account-transfer textarea {
  width: 100%; min-height: 52px; max-height: 90px;
  font-size: 10px; font-family: monospace;
  border: 3px solid var(--wood-dark); border-radius: 10px;
  background: #fffdf4; color: var(--wood-dark);
  padding: 6px; resize: vertical;
}

/* ---------- Daily quests ---------- */
.tower-grid { grid-template-columns: repeat(2, 1fr); }
.tower-tile canvas { width: 64px; height: 64px; }
.tower-up { margin-top: 6px; font-size: 15px; }
#quest-list { display: flex; flex-direction: column; gap: 10px; }
.quest-row {
  background: #fff8e6; border: 3px solid var(--wood-dark); border-radius: 14px;
  padding: 10px 12px;
}
.quest-row.claimable { border-color: #e8791f; box-shadow: 0 0 14px #ffc93c; }
.quest-row.claimed { opacity: 0.7; }
.quest-info { display: flex; justify-content: space-between; font-size: 15px; }
.quest-info span { font-weight: bold; }
.quest-bar {
  height: 12px; margin: 8px 0;
  background: #4a2c12; border: 2px solid var(--wood-dark); border-radius: 8px; overflow: hidden;
}
.quest-bar div { height: 100%; background: linear-gradient(#ffe07a, #e8a51f); transition: width 0.3s; }
.quest-foot { display: flex; align-items: center; justify-content: space-between; }
.quest-rew { display: flex; align-items: center; gap: 4px; font-size: 16px; font-weight: bold; }
.quest-rew .icon { width: 26px; height: 26px; }
.quest-done { font-size: 14px; font-weight: bold; color: #3f9a2a; }

/* ---------- Battle screen ---------- */
#battle-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--grass-dark);
  z-index: 10;
}
.canvas-wrap { flex: 1; min-height: 0; overflow: hidden; }
#battle-canvas { display: block; cursor: pointer; } /* size is set in fitCanvas() */

.hand {
  background: var(--wood);
  border-top: 5px solid var(--wood-dark);
  padding: 8px 12px 12px;
}
.feed-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.feed-icon { width: 30px; height: 30px; }
.feed-track {
  flex: 1; height: 16px;
  background: #4a2c12; border: 2px solid var(--wood-dark); border-radius: 10px; overflow: hidden;
}
#feed-fill { height: 100%; width: 50%; background: linear-gradient(#ffe07a, #e8a51f); }
#feed-count { color: var(--cream); font-size: 22px; font-weight: bold; min-width: 24px; text-align: center; }

#hand-cards { display: flex; gap: 8px; justify-content: center; align-items: flex-end; }
.next-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  margin-right: 6px;
  color: var(--cream); font-size: 11px; font-weight: bold;
}
.next-card canvas {
  width: 44px; height: 44px;
  background: var(--cream); border: 3px solid var(--wood-dark); border-radius: 10px;
  opacity: 0.85;
}
.hand-card {
  position: relative;
  width: 80px; height: 98px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--cream);
  border: 3px solid var(--wood-dark);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--wood-dark);
  transition: transform 0.1s;
}
.hand-card canvas { width: 60px; height: 60px; }
.hand-card .hand-name { font-size: 12px; font-weight: bold; color: var(--wood-dark); }
.hand-card.selected { transform: translateY(-10px); background: #fff1b8; border-color: #e8791f; }
.hand-card.too-expensive { filter: grayscale(0.8) brightness(0.8); }
.hand-card.locked { background: #c9b99a; cursor: default; }
.hand-card.locked .icon { width: 40px; height: 40px; }
.cost-badge {
  position: absolute; top: -8px; left: -8px;
  width: 26px; height: 26px; line-height: 20px;
  background: var(--gold); border: 3px solid #7a5a10; border-radius: 50%;
  font-weight: bold; color: #5a3a10; font-size: 14px;
}

/* Result popup */
#result {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(30, 20, 5, 0.55);
}
.result-box {
  background: var(--cream);
  border: 5px solid var(--wood-dark);
  border-radius: 22px;
  padding: 24px 40px;
  text-align: center;
  box-shadow: 0 8px 0 var(--wood-dark);
}
.result-box h2 { font-size: 36px; }
.result-box p { font-size: 18px; margin-top: 6px; }
#result-chest { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px auto 0; font-weight: bold; max-width: 260px; }
#result-chest .icon { width: 44px; height: 44px; }

/* Countdown + overtime polish */
#countdown {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(30, 20, 5, 0.45);
  z-index: 20; pointer-events: none;
}
#countdown span {
  font-size: 110px; font-weight: bold; color: var(--cream);
  text-shadow: 4px 4px 0 var(--wood-dark), 0 0 30px rgba(255, 201, 60, 0.8);
  animation: countpop 0.9s ease-out;
}
@keyframes countpop {
  0% { transform: scale(1.8); opacity: 0; }
  25% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.95); opacity: 1; }
}
#overtime-banner {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(194, 59, 43, 0.95); color: #fff6e0;
  font-weight: bold; font-size: 15px; padding: 8px 18px; border-radius: 14px;
  border: 3px solid #5a1d12; box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  z-index: 15; white-space: nowrap;
  animation: otpulse 1.2s ease-in-out infinite;
}
@keyframes otpulse { 50% { transform: translateX(-50%) scale(1.05); } }

/* ---------- Trophies, arenas, locked cards ---------- */
.pills { display: flex; gap: 8px; }
.big-btn:disabled { filter: grayscale(1); opacity: 0.6; cursor: default; transform: none; }

.arena-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; }
.arena-nav .arena-label { margin-bottom: 0; }
.arena-arrow {
  width: 36px; height: 36px;
  font-size: 26px; font-weight: bold; line-height: 30px;
  color: var(--cream); background: var(--wood);
  border: 3px solid var(--wood-dark); border-radius: 50%;
}
.arena-arrow:disabled { opacity: 0.3; cursor: default; }

.arena-preview-wrap { position: relative; width: fit-content; margin: 0 auto; }
.arena-lock {
  position: absolute; inset: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: rgba(30, 20, 5, 0.6); border-radius: 10px;
  color: var(--cream); font-size: 20px; font-weight: bold;
}
.arena-lock .icon { width: 64px; height: 64px; }

.arena-progress { margin: 6px auto 0; max-width: 320px; font-size: 14px; font-weight: bold; }
.arena-bar { position: relative; height: 18px; margin-top: 4px; background: #d9c59a; border: 2px solid var(--wood-dark); border-radius: 9px; overflow: hidden; }
.arena-bar div { height: 100%; background: linear-gradient(#ffe07a, #e8a51f); }
.arena-bar b { position: absolute; inset: 0; font-size: 12px; line-height: 14px; }

.arena-cards-title { margin-top: 10px; font-size: 13px; font-weight: bold; }
.arena-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 6px; }
.arena-card-item {
  display: flex; flex-direction: column; align-items: center;
  width: 64px; padding: 3px;
  background: #fff8e6; border: 3px solid; border-radius: 10px;
  font-size: 10px; font-weight: bold;
}
.arena-card-item canvas { width: 44px; height: 44px; }
.arena-card-item.locked canvas, .card-tile.locked canvas { filter: grayscale(1) brightness(0.6); }
.arena-card-item.locked { opacity: 0.75; }

.card-tile.locked { background: #e2d4b2; }
.tile-lock { display: flex; align-items: center; gap: 3px; font-size: 12px; font-weight: bold; }
.tile-lock .icon { width: 16px; height: 16px; }
.upgrade-need .icon { width: 16px; height: 16px; vertical-align: middle; }

.chest-arena { font-size: 10px; font-weight: bold; background: var(--wood); color: var(--cream); padding: 0 6px; border-radius: 6px; }
.reward-card { position: relative; }
.new-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; padding: 1px 6px;
  background: #e05a47; color: #fff; border-radius: 8px; font-size: 10px; font-weight: bold;
}
#result-chest { flex-wrap: wrap; }
.new-arena { width: 100%; color: #3f9a2a; font-size: 18px; }

/* Arena list popup */
.arena-preview-wrap { cursor: pointer; }
.arena-hint { font-size: 12px; opacity: 0.75; }
.arena-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; max-height: 65vh; overflow-y: auto; padding-right: 4px; }
.arena-entry {
  padding: 10px;
  background: #fff8e6;
  border: 3px solid var(--wood-dark);
  border-radius: 14px;
  text-align: left;
}
.arena-entry.current { border-color: #e8791f; box-shadow: 0 0 10px var(--gold); }
.arena-entry.locked { background: #e2d4b2; }
.arena-entry.locked .arena-thumb { filter: grayscale(0.8) brightness(0.7); }
.arena-entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 16px; }
.arena-entry-trophies { display: flex; align-items: center; gap: 3px; font-weight: bold; }
.arena-entry-trophies .icon { width: 20px; height: 20px; }
.arena-entry-body { display: flex; gap: 10px; align-items: flex-start; }
.arena-thumb { width: 96px; border: 3px solid var(--wood-dark); border-radius: 8px; flex-shrink: 0; }
.arena-entry .arena-cards { justify-content: flex-start; }
.arena-entry .arena-cards-title { margin-top: 0; }

/* ---------- Wooden scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--wood) rgba(90, 53, 21, 0.15); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: rgba(90, 53, 21, 0.15); border-radius: 6px; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #b27a3f, var(--wood));
  border: 2px solid var(--wood-dark);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(90deg, #c68a4c, #9a6a3a); }
.arena-no-cards { font-size: 13px; font-style: italic; opacity: 0.75; }
