@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --bg: #1a1510;
  --bg-warm: #2a2018;
  --ink: #f0ead6;
  --ink-dim: rgba(240, 234, 214, 0.6);
  --ink-muted: rgba(240, 234, 214, 0.35);
  --gold: #ffcc00;
  --gold-soft: #ffe066;
  --accent: #5ef07a;
  --accent-dim: rgba(94, 240, 122, 0.15);
  --wheat-c: #f7c948;
  --corn-c: #84cc16;
  --harvest-c: #fb923c;
  --danger: #f87171;
  --info: #60a5fa;
  --element-plant: #5ef07a;
  --element-fire: #ff6b4a;
  --element-water: #4aafff;
  --element-earth: #d4a44a;
  --rarity-rare: #60a5fa;
  --rarity-epic: #c084fc;
  --panel-bg: rgba(40, 30, 20, 0.75);
  --glass: rgba(255, 240, 200, 0.06);
  --glass-border: rgba(200, 170, 120, 0.15);
  --glass-hover: rgba(255, 240, 200, 0.1);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  font-family: var(--font-body);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { border: none; cursor: pointer; font: inherit; color: inherit; }
button:disabled { opacity: 0.35; cursor: not-allowed; filter: saturate(0.3); }

/* ===== GAME SHELL ===== */

.game-shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-columns: 1fr 240px;
  grid-template-areas:
    "top    top"
    "tabs   tabs"
    "map    panel"
    "bottom bottom";
}

/* ===== TOP HUD ===== */

.hud-top {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: linear-gradient(180deg, rgba(35,25,15,0.95) 0%, rgba(35,25,15,0.88) 100%);
  border-bottom: 1px solid var(--glass-border);
  z-index: 10;
  gap: 14px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  background: linear-gradient(135deg, var(--gold), #fff8dc, var(--gold));
  background-size: 200% 200%;
  animation: title-shimmer 4s ease-in-out infinite;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.02em;
}

@keyframes title-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hud-pill {
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.hud-pill.level {
  background: linear-gradient(135deg, rgba(94,240,122,0.15), rgba(94,240,122,0.08));
  border: 1.5px solid rgba(94, 240, 122, 0.3);
  color: var(--accent);
  box-shadow: 0 0 8px rgba(94, 240, 122, 0.1);
  font-size: 0.9rem;
  font-weight: 700;
}

.xp-track {
  width: 100px; height: 10px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255,255,255,0.06);
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: inherit;
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
  width: 0%;
  box-shadow: 0 0 8px rgba(94, 240, 122, 0.35);
}

.xp-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  pointer-events: none;
}

.hud-resources {
  display: flex;
  gap: 6px;
}

.res {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-weight: 600;
  font-size: 0.85rem;
  transition: transform 180ms cubic-bezier(0.34, 1.56, 0.64, 1), background 200ms ease;
  cursor: default;
  user-select: none;
}

.res:hover {
  transform: scale(1.06);
  background: var(--glass-hover);
}

.res-icon { font-size: 0.8rem; opacity: 0.65; }
.icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.12em; flex-shrink: 0; }
.res .icon { font-size: 1rem; opacity: 1; }
.res-coins { background: linear-gradient(135deg, rgba(255,204,0,0.1), rgba(255,180,0,0.05)); border-color: rgba(255,204,0,0.2); padding: 5px 14px; }
.res-coins .res-value { font-size: 1rem; font-weight: 800; color: var(--gold); font-family: var(--font-display); }
.res-separator { width: 1px; height: 20px; background: rgba(200,170,120,0.15); margin: 0 2px; flex-shrink: 0; }
.inv-gauge { width: 40px; height: 5px; border-radius: var(--radius-pill); background: rgba(255,255,255,0.08); overflow: hidden; margin-left: 4px; }
.inv-gauge-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: inherit; transition: width 400ms ease, background 400ms ease; }
.inv-gauge-fill.warning { background: linear-gradient(90deg, #fb923c, #f87171); }
.inv-gauge-fill.full { background: #f87171; }
.wheat-res span:last-child { color: var(--wheat-c); }
.corn-res span:last-child { color: var(--corn-c); }
#coinChip span:last-child { color: var(--gold); }

/* ===== MAP AREA ===== */

.map-area {
  grid-area: map;
  position: relative;
  overflow: hidden;
  background: #1a3520;
}

#farmCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.boost-overlay {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  padding: 5px 18px;
  border-radius: var(--radius-pill);
  background: rgba(96, 165, 250, 0.12);
  border: 1.5px solid rgba(96, 165, 250, 0.3);
  color: #93c5fd;
  font-size: 0.7rem;
  font-weight: 800;
  animation: boost-pulse 2.5s ease-in-out infinite;
  pointer-events: none;
  backdrop-filter: blur(8px);
  letter-spacing: 0.02em;
}

@keyframes boost-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(96,165,250,0); }
  50% { box-shadow: 0 0 20px 4px rgba(96,165,250,0.2); }
}

/* ===== BOTTOM ACTION BAR ===== */

.hud-bottom {
  grid-area: bottom;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  background: linear-gradient(0deg, rgba(35,25,15,0.95) 0%, rgba(35,25,15,0.88) 100%);
  border-top: 1px solid var(--glass-border);
  z-index: 10;
  flex-wrap: wrap;
}

.action-group {
  display: flex;
  gap: 4px;
}

.action-group + .action-group {
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,0.06);
}

/* ===== BUTTONS ===== */

.btn {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* Beveled 3D game button */
  border: none;
  border-bottom: 3px solid rgba(0,0,0,0.25);
  border-top: 1px solid rgba(255,255,255,0.15);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  transition: transform 80ms ease, box-shadow 120ms ease, border-bottom-width 80ms ease, filter 80ms ease;
}

.btn .icon { font-size: 1.1em; }

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
  border-bottom-width: 1px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  filter: brightness(0.95);
}

.btn-wheat {
  background: linear-gradient(135deg, #d4a017 0%, #b8860b 100%);
  border-color: rgba(160, 120, 24, 0.5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(212, 160, 23, 0.25);
}
.btn-wheat:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(212, 160, 23, 0.4); }

.btn-corn {
  background: linear-gradient(135deg, #5da832 0%, #468a22 100%);
  border-color: rgba(70, 138, 34, 0.5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(93, 168, 50, 0.2);
}
.btn-corn:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(93, 168, 50, 0.35); }

.btn-harvest {
  background: linear-gradient(135deg, #e56c2a 0%, #c4501a 100%);
  border-color: rgba(197, 80, 26, 0.5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(229, 108, 42, 0.25);
}
.btn-harvest:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(229, 108, 42, 0.4); }

.btn-sell {
  background: linear-gradient(135deg, #7a6520 0%, #5c4b18 100%);
  border-color: rgba(122, 101, 32, 0.4);
  color: var(--gold-soft);
  box-shadow: 0 2px 8px rgba(122, 101, 32, 0.2);
}
.btn-sell:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(255, 204, 0, 0.2); }

.btn-build {
  background: linear-gradient(135deg, #5a4030 0%, #3e2a1c 100%);
  border-color: rgba(180, 130, 80, 0.2);
  color: #dea868;
  box-shadow: 0 2px 8px rgba(90, 64, 48, 0.3);
}
.btn-build:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(222, 168, 104, 0.2); }

.btn-hire {
  background: linear-gradient(135deg, #1e4a28 0%, #15351c 100%);
  border-color: rgba(94, 240, 122, 0.2);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(30, 74, 40, 0.3);
}
.btn-hire:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(94, 240, 122, 0.2); }

.btn-upgrade {
  background: linear-gradient(135deg, #2a4a6a 0%, #1e3854 100%);
  border-color: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
  box-shadow: 0 2px 8px rgba(42, 74, 106, 0.3);
}
.btn-upgrade:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(96, 165, 250, 0.2); }

.btn-upgrade.owned {
  background: rgba(94, 240, 122, 0.08);
  color: var(--accent);
  border-color: rgba(94, 240, 122, 0.2);
  box-shadow: none;
}

/* ===== RIGHT PANEL ===== */

.panel-right {
  grid-area: panel;
  padding: 12px;
  background: rgba(35, 25, 15, 0.92);
  border-left: 1px solid var(--glass-border);
  overflow-y: auto;
  z-index: 5;
}

.panel-right::-webkit-scrollbar { width: 3px; }
.panel-right::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: var(--radius-pill); }

.panel-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: 8px;
}

/* Worker cards */
.worker-list { display: grid; gap: 6px; }

.worker-card {
  padding: 8px 11px;
  border-radius: var(--radius-md);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  transition: background 200ms ease, border-color 200ms ease, transform 200ms ease;
}

.worker-card:hover {
  background: var(--glass-hover);
  border-color: rgba(255,255,255,0.12);
  transform: translateX(-2px);
}

.worker-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gold-soft);
}

.worker-info {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--ink-dim);
  margin-top: 2px;
  letter-spacing: 0.01em;
}

.worker-xp-track {
  height: 3px; border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.06);
  margin-top: 5px; overflow: hidden;
}

.worker-xp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: inherit;
  transition: width 500ms cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 6px rgba(94, 240, 122, 0.3);
}

.worker-xp-fill.max {
  width: 100%;
  background: linear-gradient(90deg, var(--gold), #ff8c00);
  box-shadow: 0 0 8px rgba(255, 204, 0, 0.4);
}

/* Plot list */
.plot-list { display: grid; gap: 4px; }

.plot-status {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  background: var(--glass);
  border: 1px solid transparent;
  font-weight: 500;
  transition: background 200ms ease, transform 200ms ease;
}

.plot-status:hover {
  background: var(--glass-hover);
  transform: translateX(-2px);
}

.plot-status.locked { opacity: 0.25; }

.plot-status.ready {
  background: rgba(255, 204, 0, 0.08);
  border-color: rgba(255, 204, 0, 0.18);
  color: var(--gold-soft);
}

.plot-status.growing { color: var(--accent); }
.plot-id { font-weight: 800; margin-right: 4px; opacity: 0.4; }

/* Value pop animation */
.value-pop {
  animation: value-pop 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes value-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.35); filter: brightness(1.3); }
  100% { transform: scale(1); }
}

/* Plot mini progress bar in side panel */
.plot-mini-bar {
  height: 2px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.06);
  margin-top: 4px;
  overflow: hidden;
}
.plot-mini-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: inherit;
  transition: width 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Ready plot pulse in sidebar */
.plot-status.ready {
  animation: ready-pulse 2s ease-in-out infinite;
}
@keyframes ready-pulse {
  0%, 100% { background: rgba(255, 204, 0, 0.08); }
  50% { background: rgba(255, 204, 0, 0.15); }
}

/* ===== CREATURE WORKER ASSIGNMENT ===== */

.element-dot-sm {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.element-dot-sm.plant { background: var(--element-plant); box-shadow: 0 0 4px var(--element-plant); }
.element-dot-sm.fire  { background: var(--element-fire);  box-shadow: 0 0 4px var(--element-fire); }
.element-dot-sm.water { background: var(--element-water); box-shadow: 0 0 4px var(--element-water); }
.element-dot-sm.earth { background: var(--element-earth); box-shadow: 0 0 4px var(--element-earth); }

/* Assigned creature card on plot */
.plot-creature-card {
  margin-top: 5px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.plot-creature-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.plot-creature-card.plant { border-color: rgba(94,240,122,0.25); }
.plot-creature-card.plant::before { background: var(--element-plant); }
.plot-creature-card.fire  { border-color: rgba(255,107,74,0.25); }
.plot-creature-card.fire::before  { background: var(--element-fire); }
.plot-creature-card.water { border-color: rgba(74,175,255,0.25); }
.plot-creature-card.water::before { background: var(--element-water); }
.plot-creature-card.earth { border-color: rgba(212,164,74,0.25); }
.plot-creature-card.earth::before { background: var(--element-earth); }

.plot-creature-card:hover {
  box-shadow: 0 0 8px rgba(255,255,255,0.05);
}

.plot-creature-top {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
}
.plot-creature-name {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plot-creature-level {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--gold-soft);
  background: rgba(255,204,0,0.1);
  padding: 0 4px;
  border-radius: var(--radius-pill);
}
.plot-creature-bonus-line {
  font-size: 0.6rem;
  color: var(--ink-dim);
  font-style: italic;
  margin-top: 2px;
}
.plot-creature-xp-track {
  height: 2px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.06);
  margin-top: 4px;
  overflow: hidden;
}
.plot-creature-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: inherit;
  box-shadow: 0 0 4px rgba(94,240,122,0.3);
  transition: width 0.3s ease;
}

.btn-unassign {
  background: none;
  border: 1px solid rgba(255,90,90,0.2);
  color: rgba(255,90,90,0.5);
  border-radius: 50%;
  width: 16px; height: 16px;
  font-size: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
  transition: all 0.15s;
}
.btn-unassign:hover {
  background: rgba(255,90,90,0.15);
  color: #ff6b6b;
  border-color: rgba(255,90,90,0.5);
  transform: scale(1.1);
}

/* Empty plot — assign button */
.plot-creature.empty {
  margin-top: 4px;
}
.btn-assign {
  background: rgba(94,240,122,0.05);
  border: 1px dashed rgba(94,240,122,0.2);
  color: rgba(94,240,122,0.6);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 0.65rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
  width: 100%;
}
.btn-assign:hover {
  background: rgba(94,240,122,0.1);
  color: var(--accent);
  border-color: rgba(94,240,122,0.4);
  box-shadow: 0 0 8px rgba(94,240,122,0.1);
}

/* Creature picker dropdown */
.creature-picker {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
  padding: 6px;
  background: rgba(20,15,10,0.95);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: pickerIn 0.15s ease-out;
}
@keyframes pickerIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.creature-pick-option {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.7rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  font-family: var(--font-body);
}
.creature-pick-option:hover {
  background: rgba(94,240,122,0.08);
  border-color: rgba(94,240,122,0.3);
  transform: translateX(-2px);
  box-shadow: 0 0 8px rgba(94,240,122,0.1);
}
.pick-bonus {
  margin-left: auto;
  font-size: 0.6rem;
  opacity: 0.5;
  font-style: italic;
  color: var(--gold-soft);
}

/* ===== MODE TABS ===== */

.mode-tabs {
  grid-area: tabs;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 16px;
  background: rgba(30,22,12,0.92);
  border-bottom: 1px solid var(--glass-border);
  z-index: 10;
  height: 30px;
}

.mode-tab {
  padding: 3px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: transparent;
  color: var(--ink-muted);
  transition: all 200ms ease;
}
.mode-tab.active {
  background: var(--glass);
  color: var(--gold);
  border: 1px solid rgba(255,204,0,0.2);
}
.mode-tab:hover:not(.active) {
  color: var(--ink-dim);
}

.energy-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-weight: 700;
  font-size: 0.7rem;
  color: #ffd740;
}
.energy-icon { font-size: 0.75rem; }

/* ===== CREATURE PANEL ===== */

.roster-list { display: grid; gap: 8px; }

.creature-card {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  transition: background 200ms ease, border-color 200ms ease, transform 200ms ease, box-shadow 200ms ease;
}
.creature-card:hover {
  background: var(--glass-hover);
  border-color: rgba(255,255,255,0.15);
  transform: translateX(-2px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.creature-card.selected {
  border-color: var(--gold);
  background: rgba(255, 204, 0, 0.08);
  box-shadow: 0 0 12px rgba(255, 204, 0, 0.15);
}
.creature-card.unavailable { opacity: 0.35; pointer-events: none; }

.creature-card-top {
  font-weight: 800;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.creature-nickname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-badge {
  font-size: 0.6rem;
  font-weight: 900;
  background: rgba(94, 240, 122, 0.2);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

.element-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 4px currentColor;
}
.element-dot.plant { background: var(--element-plant); color: var(--element-plant); }
.element-dot.fire { background: var(--element-fire); color: var(--element-fire); }
.element-dot.water { background: var(--element-water); color: var(--element-water); }
.element-dot.earth { background: var(--element-earth); color: var(--element-earth); }

.grade-badge {
  font-size: 0.6rem;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  margin-left: auto;
  flex-shrink: 0;
}
.grade-badge.S { background: rgba(255,215,64,0.2); color: #ffd740; }
.grade-badge.A { background: rgba(255,140,74,0.2); color: #ff8c4a; }
.grade-badge.B { background: rgba(96,165,250,0.2); color: #60a5fa; }
.grade-badge.C { background: rgba(138,138,138,0.15); color: #8a8a8a; }

.creature-card-stats {
  font-size: 0.68rem;
  color: var(--ink-dim);
  margin-top: 4px;
}

.creature-hp-track {
  height: 5px; border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.06);
  margin-top: 6px; overflow: hidden;
}
.creature-hp-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 400ms cubic-bezier(0.22, 1, 0.36, 1);
}
.creature-hp-fill.hp-high { background: var(--accent); }
.creature-hp-fill.hp-mid { background: #ffd740; }
.creature-hp-fill.hp-low { background: var(--danger); }

.creature-card-hp-text {
  font-size: 0.6rem;
  color: var(--ink-muted);
  margin-top: 2px;
  text-align: right;
}

.creature-status {
  display: block;
  font-size: 0.62rem;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.creature-status.ko {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  font-weight: 700;
}
.creature-status.cooldown {
  background: rgba(96, 165, 250, 0.08);
  color: var(--info);
  font-style: italic;
}

/* Heal button */
.btn-heal {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #3a2a2a 0%, #4a2020 100%);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: #f87171;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-heal:hover:not(:disabled) {
  background: linear-gradient(135deg, #4a3030 0%, #5a2828 100%);
  box-shadow: 0 2px 8px rgba(248, 113, 113, 0.2);
  transform: translateY(-1px);
}
.btn-heal.disabled,
.btn-heal:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  font-size: 0.6rem;
}

.creature-empty-hint {
  text-align: center;
  padding: 20px 10px;
  color: var(--ink-dim);
  font-size: 0.75rem;
}
.creature-empty-hint .hint-sub {
  font-size: 0.65rem;
  color: var(--ink-muted);
  margin-top: 6px;
}

/* Combat log panel */
.combat-log-list { display: grid; gap: 4px; }
.combat-log-entry {
  font-size: 0.68rem;
  color: var(--ink-dim);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--glass);
  border-left: 2px solid var(--glass-border);
}

/* Context help (side panel) */
.context-help-container {
  margin-top: 12px;
}
.context-help {
  background: rgba(255, 240, 200, 0.04);
  border: 1px solid rgba(255, 240, 200, 0.08);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.context-help .help-title {
  font-weight: 800;
  font-size: 0.72rem;
  color: var(--ink);
  margin-bottom: 6px;
}
.context-help .help-desc {
  font-size: 0.65rem;
  color: var(--ink-dim);
  line-height: 1.4;
  margin-bottom: 6px;
}
.context-help .help-stat {
  font-size: 0.65rem;
  padding: 2px 0;
}
.context-help .help-stat.good { color: var(--accent); }
.context-help .help-stat.bad { color: var(--danger); }
.context-help .help-stat.neutral { color: var(--info); }
.context-help .help-hint {
  font-size: 0.6rem;
  color: var(--ink-muted);
  margin-top: 6px;
  font-style: italic;
}

/* ===== CREATURE BUTTONS ===== */

.btn-expedition {
  background: linear-gradient(135deg, #2a5a3a 0%, #1a4028 100%);
  border-color: rgba(94, 240, 122, 0.25);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(30, 90, 58, 0.3);
  font-weight: 700;
}
.btn-expedition:hover:not(:disabled) { box-shadow: 0 4px 16px rgba(94, 240, 122, 0.25); }
.btn-expedition.active-expedition {
  background: linear-gradient(135deg, #4a3020 0%, #3a2018 100%);
  border-color: rgba(255, 107, 74, 0.3);
  color: #ff6b4a;
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 2px 8px rgba(255, 107, 74, 0.2); }
  50% { box-shadow: 0 4px 20px rgba(255, 107, 74, 0.4); }
}

.btn-back {
  background: linear-gradient(135deg, #3a3a4a 0%, #2a2a38 100%);
  border-color: rgba(255,255,255,0.1);
  color: var(--ink-dim);
  font-weight: 600;
}

.btn-attack {
  background: linear-gradient(135deg, #c04030 0%, #903020 100%);
  border-color: rgba(255, 107, 74, 0.4);
  color: #fff;
  box-shadow: 0 2px 8px rgba(192, 64, 48, 0.3);
  font-weight: 700;
  font-size: 0.85rem;
}
.btn-attack:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(255, 107, 74, 0.4);
  transform: translateY(-1px);
}

.btn-capture {
  background: linear-gradient(135deg, #4a3a70 0%, #352860 100%);
  border-color: rgba(192, 132, 252, 0.3);
  color: #c084fc;
  box-shadow: 0 2px 8px rgba(74, 58, 112, 0.3);
  font-weight: 600;
}
.btn-capture:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(192, 132, 252, 0.3);
  transform: translateY(-1px);
}

.btn-flee {
  background: linear-gradient(135deg, #4a4a30 0%, #3a3a20 100%);
  border-color: rgba(255, 215, 64, 0.2);
  color: #ffd740;
  font-weight: 600;
}

.btn-start-expedition {
  background: linear-gradient(135deg, #2a6a3a 0%, #1a5028 100%);
  border-color: rgba(94, 240, 122, 0.3);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(30, 106, 58, 0.3);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 20px;
}
.btn-start-expedition:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(94, 240, 122, 0.4);
  transform: translateY(-1px);
}

/* ===== ORIENTATION GUARD ===== */

#orientation-guard {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(10,16,28,0.97); color: var(--ink);
  align-items: center; justify-content: center; flex-direction: column;
  backdrop-filter: blur(20px);
}
.orientation-content { text-align: center; }
.orientation-icon { font-size: 3rem; margin-bottom: 16px; }
#orientation-guard p { font-size: 1.1rem; font-weight: 700; }

/* ===== LEVEL BLOCK ===== */

.level-block {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== TOAST SYSTEM ===== */

.toast-container {
  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  pointer-events: auto;
  animation: toastIn 300ms ease, toastOut 300ms ease 2.7s forwards;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.toast-error {
  background: linear-gradient(135deg, rgba(248,113,113,0.9), rgba(220,80,80,0.9));
  border: 1px solid rgba(255,150,150,0.3);
}
.toast-success {
  background: linear-gradient(135deg, rgba(94,240,122,0.85), rgba(70,200,90,0.85));
  border: 1px solid rgba(140,255,160,0.3);
  color: #1a3010;
}
.toast-info {
  background: linear-gradient(135deg, rgba(96,165,250,0.85), rgba(70,140,230,0.85));
  border: 1px solid rgba(140,180,255,0.3);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-5px); }
}

/* ===== PANEL TOGGLE (mobile) ===== */

.panel-toggle {
  display: none;
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 48;
  background: rgba(35,25,15,0.85);
  border: 1px solid var(--glass-border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  padding: 12px 6px;
  color: var(--ink-dim);
  font-size: 1rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 150ms ease;
}
.panel-toggle:hover { background: rgba(50,38,22,0.9); }

.panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 49;
}
.panel-backdrop.open { display: block; }

/* ===== MUTE BUTTON ===== */

.btn-mute {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  padding: 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 150ms ease;
}
.btn-mute:hover { color: var(--ink); }
.btn-mute .icon { width: 1.2em; height: 1.2em; }

/* ===== BUTTON RIPPLE ===== */

.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transform: scale(0);
  animation: ripple 400ms ease-out;
  pointer-events: none;
}
@keyframes ripple {
  to { transform: scale(2.5); opacity: 0; }
}

/* ===== WORKER CARD STAGGER ===== */

.worker-card {
  animation: cardIn 200ms ease backwards;
}
.worker-card:nth-child(1) { animation-delay: 0ms; }
.worker-card:nth-child(2) { animation-delay: 40ms; }
.worker-card:nth-child(3) { animation-delay: 80ms; }
.worker-card:nth-child(4) { animation-delay: 120ms; }
@keyframes cardIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ===== ENHANCED VALUE POP ===== */

.value-pop {
  animation: value-pop 400ms cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
@keyframes value-pop {
  0% { transform: scale(1); filter: brightness(1); }
  25% { transform: scale(1.4); filter: brightness(1.4); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* ===== RESPONSIVE ===== */

@media (max-width: 700px) {
  .game-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "top" "tabs" "map" "bottom";
  }
  .panel-right {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 260px;
    transform: translateX(100%);
    transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
  }
  .panel-right.open {
    transform: translateX(0);
  }
  .panel-toggle { display: block; }
  .combat-actions { flex-wrap: wrap; justify-content: center; }
  .action-bar-main .btn { padding: 10px 12px; }
}

@media (min-width: 701px) {
  .panel-toggle { display: none !important; }
  .panel-backdrop { display: none !important; }
}

/* ===== WALLET CHIP (top HUD) ===== */

.wallet-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-dim);
  transition: background 150ms, border-color 150ms, color 150ms;
  cursor: pointer;
  white-space: nowrap;
}
.wallet-chip:hover { background: var(--glass-hover); color: var(--ink); }
.wallet-chip.status-verified {
  border-color: rgba(94, 240, 122, 0.4);
  color: var(--accent);
  background: var(--accent-dim);
}
.wallet-chip.status-pending {
  border-color: rgba(255, 204, 0, 0.35);
  color: var(--gold-soft);
}
.wallet-chip.status-error {
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--danger);
}
.wallet-chip.wallet-busy {
  opacity: 0.6;
  pointer-events: none;
}
.wallet-chip-icon { font-size: 0.85rem; }

/* ===== WALLET DROPDOWN ===== */

.wallet-dropdown {
  position: fixed;
  top: 48px;
  right: 16px;
  width: 300px;
  max-width: calc(100vw - 32px);
  background: rgba(30, 22, 14, 0.97);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
}
.wallet-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--glass-border);
}
.wallet-dropdown-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
}
.wallet-dropdown-close {
  background: none;
  font-size: 1.2rem;
  color: var(--ink-dim);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.wallet-dropdown-close:hover { color: var(--ink); background: var(--glass-hover); }

.wallet-dropdown-body {
  padding: 14px;
  font-size: 0.82rem;
  line-height: 1.5;
}
.wallet-dropdown-body .wallet-addr {
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--gold-soft);
  word-break: break-all;
  margin: 6px 0;
}
.wallet-dropdown-body .wallet-status-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.wallet-dropdown-body .wallet-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.wallet-status-dot.verified { background: var(--accent); }
.wallet-status-dot.pending { background: var(--gold); }
.wallet-status-dot.error { background: var(--danger); }
.wallet-status-dot.none { background: var(--ink-muted); }

.wallet-dropdown-body .btn-wallet-action {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin-top: 10px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.82rem;
  text-align: center;
  transition: background 150ms;
}
.btn-wallet-action.primary {
  background: linear-gradient(135deg, var(--accent), #3dd45a);
  color: #111;
}
.btn-wallet-action.primary:hover { filter: brightness(1.1); }
.btn-wallet-action.secondary {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--ink);
}
.btn-wallet-action.secondary:hover { background: var(--glass-hover); }
.btn-wallet-action:disabled { opacity: 0.4; cursor: not-allowed; }

.wallet-dropdown-body .wallet-error {
  color: var(--danger);
  font-size: 0.78rem;
  margin-top: 6px;
}
.wallet-dropdown-body .wallet-hint {
  color: var(--ink-muted);
  font-size: 0.75rem;
  margin-top: 8px;
}

/* ===== CREATURE MINT BADGES ===== */

.mint-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 4px;
}
.mint-badge.mint-none {
  display: none;
}
.mint-badge.mint-pending {
  background: rgba(255, 204, 0, 0.15);
  color: var(--gold-soft);
  border: 1px solid rgba(255, 204, 0, 0.3);
}
.mint-badge.mint-submitted {
  background: rgba(96, 165, 250, 0.15);
  color: var(--info);
  border: 1px solid rgba(96, 165, 250, 0.3);
  animation: mint-pulse 2s ease-in-out infinite;
}
.mint-badge.mint-confirmed {
  background: rgba(94, 240, 122, 0.15);
  color: var(--accent);
  border: 1px solid rgba(94, 240, 122, 0.3);
}
.mint-badge.mint-failed {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}
@keyframes mint-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.creature-token-id {
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--accent);
  margin-left: 4px;
}

.mint-meta-link {
  font-size: 0.7rem;
  color: var(--info);
  text-decoration: underline;
  cursor: pointer;
  margin-left: 6px;
}
.mint-meta-link:hover { color: var(--gold-soft); }
