:root {
  --bg: #241f29;
  --panel: #322932ee;
  --text: #fff1da;
  --muted: #c4b4ab;
  --gold: #efc682;
  --line: #efd0a52a;
  --accent: #d8b7ed;
}
body {
  font-family: 'Trebuchet MS', system-ui, sans-serif;
  background: #241f29;
}
.world-backdrop {
  background-image: linear-gradient(#241d2930, #241d2960), url('/static/game/merge/cozy-workshop.webp') !important;
  background-position: center;
  background-size: cover;
}
.topbar {
  max-width: 1320px;
  border-bottom: 0;
  padding-bottom: 8px;
}
.identity small {
  color: #e6caad;
  font-size: 9px;
  letter-spacing: .13em;
}
.identity h1 {
  color: #fff0d5;
  font-size: 19px;
}
.back, .save-status {
  background: #332b35e6;
  box-shadow: inset 0 1px #fbe3bf18;
  border-color: #efd0a533;
}
.save-status {
  color: #e8d2b8;
  border-radius: 20px;
}
main {
  max-width: 1320px;
  padding-top: 15px;
}
.overview {
  position: relative;
  padding: 22px 24px;
  border: 1px solid #f4d5ae38;
  border-radius: 26px;
  background: linear-gradient(100deg, #392c39ee, #3b303cce);
  box-shadow: inset 0 1px #fff1d822, 0 14px 40px #160f2040;
  overflow: hidden;
  gap: 18px;
}
.overview::after {
  content: '';
  position: absolute;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, #eabd7030, transparent 70%);
  top: -95px;
  right: 80px;
  pointer-events: none;
}
.welcome {
  display: flex;
  align-items: center;
  gap: 15px;
  min-width: 0;
}
.companion {
  width: 90px;
  height: 90px;
  flex: 0 0 auto;
  position: relative;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 75%, #efc68225, #bf9ee710 60%, transparent 70%);
}
.companion img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 6px #160e2940);
  animation: companion-float 6s ease-in-out infinite;
}
.eyebrow {
  color: #e7bd83;
  letter-spacing: .16em;
  font-size: 9px;
}
.overview h2 {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 500;
  font-size: 34px;
  letter-spacing: -.025em;
  color: #fff0d3;
}
.overview p {
  color: #d1beb6;
}
.world-postcard {
  width: 112px;
  height: 79px;
  object-fit: cover;
  border: 5px solid #e7d2b6;
  outline: 1px solid #fff4d838;
  border-radius: 5px;
  transform: rotate(-6deg);
  box-shadow: 0 5px 15px #120e2040;
  margin-left: auto;
}
.wallet {
  min-width: 150px;
  border-radius: 18px;
  padding: 12px 18px;
  background: linear-gradient(140deg,#62483199,#3a2c35cc);
  box-shadow: inset 0 1px #ffddab22;
  z-index: 1;
}
.wallet strong {
  color: #ffe4ab;
}
.layout {
  grid-template-columns: minmax(0,1fr) 390px;
  gap: 22px;
}
.play-panel {
  position: relative;
  padding: 23px;
  border: 1px solid #dfb88769;
  border-radius: 26px;
  background: linear-gradient(145deg,#604532,#3b2c2a 55%,#594030);
  box-shadow: inset 0 2px #ffdfab24, inset 0 -3px #251a1d90, 0 18px 45px #120e2055;
  backdrop-filter: none;
}
.field-header {
  color: #decaaf;
  margin: 0 2px 16px;
  font-size: 11px;
}
.field-header b {
  color: #ffe8b6;
}
.live-dot {
  background: #bdd897;
  box-shadow: 0 0 10px #bdd89780;
}
.board {
  gap: 9px;
  padding: 12px;
  border-radius: 20px;
  background: linear-gradient(145deg,#262331,#342934);
  border: 1px solid #120e244a;
  box-shadow: inset 0 3px 12px #0c091c55, 0 1px #f7d8a925;
}
.cell {
  background: radial-gradient(ellipse at 50% 75%,#dec09420,transparent 75%), linear-gradient(145deg,#665668,#493d50);
  border: 1px solid #e9d0ca28;
  border-radius: 18px;
  box-shadow: inset 0 1px #fff0d71a, 0 3px 0 #1b142946;
  padding: 4px;
}
.cell img {
  width: 97%;
  height: 97%;
  filter: drop-shadow(0 6px 4px #150e234f);
}
.cell.empty {
  border-style: solid;
  background: #1c182b45;
  border-color: #c6aabb15;
  box-shadow: inset 0 2px 5px #100c222b;
}
.cell.empty::after {
  content: '✧';
  font-size: 16px;
  color: #c5adc133;
}
.cell .rank {
  left: auto;
  right: 5px;
  bottom: 4px;
  padding: 0 5px;
  border-radius: 6px;
  background: #241a38a6;
  color: #f9dbac;
  font-size: 9px;
  text-shadow: none;
}
.cell.selected {
  border-color: #f6d491;
  box-shadow: 0 0 0 2px #f6d49135, inset 0 0 20px #ffdd7c22;
}
.cell.pair {
  border-color: #c3dfa5;
  box-shadow: 0 0 15px #c3dfa533;
}
.cell.match { border-color: #b8dcba; box-shadow: inset 0 0 18px #ace3bd2a, 0 0 0 1px #d5e8c74a; }
.cell.chain-ready { border-color: #ffe09a; box-shadow: 0 0 0 2px #ffe09a87, 0 0 22px #ffd27d6a, inset 0 0 16px #ffe09a36; }
.cell.chain-ready::before { content: '✦'; position: absolute; z-index: 2; top: 1px; left: 5px; color: #ffe6a2; font-size: 15px; text-shadow: 0 0 7px #ffc661; }
.cell.chain-bloom { animation: chain-bloom .75s ease-out; }
@keyframes chain-bloom { 35% { transform: scale(1.19); border-color: #fff2bd; box-shadow: 0 0 0 4px #ffe0945c, 0 0 42px #ffd886; } 100% { transform: scale(1); } }
.selection {
  color: #dccabb;
  min-height: 46px;
}
.order-peek {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  padding: 11px 12px;
  border: 1px solid #e2bd8050;
  border-radius: 13px;
  background: linear-gradient(105deg,#74604166,#302b38b8);
}
.order-peek span { min-width: 0; }
.order-peek small { display: block; color: #d2bcab; font-size: 10px; line-height: 1.35; }
.order-peek b { display: block; color: #ffe3af; font-size: 13px; line-height: 1.4; }
.order-peek button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid #e6c58e80;
  border-radius: 11px;
  background: #dcb779;
  color: #3b2b24;
  font-size: 12px;
  font-weight: 800;
}
.order-peek button:disabled { background: #66523e; color: #dbcbba; }
.x-workshop-level {
  margin: 12px 0 18px;
  padding: 16px;
  border: 1px solid #e3bf8166;
  border-radius: 16px;
  background: linear-gradient(130deg,#654c3d,#443649);
}
.x-workshop-level strong { display: block; color: #ffe3ae; font-size: 17px; }
.x-workshop-level small { display: block; margin-top: 4px; color: #dac6b4; }
.x-workshop-level .progress-track { margin-bottom: 0; }
.x-order-ready { border-color: #d4bc80a8 !important; box-shadow: 0 0 19px #e2b26a25; }
.x-order-face { display: flex; gap: 12px; align-items: center; }
.x-order-face img { width: 74px; height: 74px; flex: 0 0 auto; object-fit: contain; }
.x-order-face small { color: #dabb8f; font-size: 10px; }
.x-order-face strong { display: block; color: #f7e1c0; font-size: 16px; }
.x-order-face p { margin: 3px 0 0; }
.spawn-button {
  background: linear-gradient(130deg,#f4d298,#d6ad73);
  color: #473125;
  border-radius: 15px;
  box-shadow: inset 0 1px #fff1d880, 0 4px 0 #2a1b1c70, 0 8px 20px #e8b86620;
  min-height: 52px;
}
.spawn-button small {
  background: #6b47151a;
}
.action {
  background: #493c47;
  color: #f7e4c8;
  border-radius: 14px;
}
.extra-actions button {
  color: #e0c9b5;
  min-height: 38px;
  font-size: 11px;
}
.onboarding {
  position: relative;
  padding: 13px 15px;
  background: #f4dfbde8;
  border: 1px solid #f9e8c7;
  color: #715c51;
  border-radius: 4px 14px 14px 14px;
  box-shadow: 0 4px 12px #140d1c25;
}
.onboarding b {
  color: #664a36;
}
.side-panel {
  border-radius: 26px;
  background: #332b36ed;
  border-color: #eacaa83b;
  box-shadow: inset 0 1px #fbe2bd20, 0 20px 40px #0e0b2240;
  backdrop-filter: blur(8px);
}
.notebook-heading {
  padding: 16px 19px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.notebook-heading b {
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  color: #f3dbb9;
}
.notebook-heading small {
  color: #b6a399;
  font-size: 10px;
}
.tabs {
  background: #2b242c66;
  padding: 9px 12px 12px;
  gap: 5px;
}
.tabs button {
  flex: 1 0 29%;
  color: #c4b3ae;
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 10px;
  padding: 7px 4px;
  min-height: 39px;
}
.tabs button.active {
  color: #ffe4b7;
  background: #66503c;
  border-color: #e8c7974d;
  box-shadow: inset 0 1px #e8c79722;
}
.tab-icon {
  display: inline-block;
  font-size: 14px;
  margin-right: 5px;
  color: #d7b594;
}
.panel-content {
  padding: 19px;
  max-height: 580px;
  scrollbar-color: #907663 #332b36;
}
.panel-content h3 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 23px;
  color: #f8dfb9;
}
.panel-content p {
  font-size: 12px;
  line-height: 1.65;
  color: #c9b8b0;
}
.world-card {
  background: #443642;
  border-color: #dec8af24;
  border-radius: 15px;
  padding: 11px;
}
.world-card.current {
  background: #62503f;
  border-color: #dab7837a;
}
.world-card img {
  width: 76px;
  height: 53px;
  border: 2px solid #ddc7a580;
  border-radius: 8px;
}
.world-card small {
  color: #cbb6ac;
}
.world-card i {
  color: #e8c48a;
}
.collect-card, .upgrade, .quest, .achievement, .x-card {
  background: #473947;
  border-color: #d3b8a629;
  box-shadow: inset 0 1px #fce4c00a;
}
.collect-card {
  border-radius: 15px;
  background: radial-gradient(ellipse at 50% 80%,#d8b69b20,transparent 80%),#443644;
}
.collect-card small {
  color: #dbc8b6;
  font-size: 9px;
}
.upgrade button, .quest button, .achievement button, .gift button, .x-card > button, .x-party > button, .panel-content > button {
  border: 1px solid #e9c68c45;
  background: #72563f55;
  color: #ffe0a9;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 11px;
}
.x-summary span, .statistics span {
  background: #241e2b60;
  border-color: #ead1ac21;
  color: #ceb9ad;
}
.x-summary b, .statistics b {
  color: #f7ddae;
}
.x-card > small, .x-journal time, .x-journal small {
  color: #cdb6aa;
}
.x-journal li {
  border-left-color: #cea46e;
}
.progress-track i {
  background: linear-gradient(90deg,#acb792,#e7c78f);
}
.settings-row select, .settings-actions button {
  background: #49394b;
  color: #f4e3cd;
}
dialog {
  background: #3c303c;
  border-color: #eac79866;
  box-shadow: 0 25px 100px #140c2499;
}
dialog::backdrop {
  background: #21152599;
}
.toast {
  color: #ffe9c5;
  background: #503d40f5;
  border-color: #dab58466;
  border-radius: 19px;
}
footer {
  color: #e2cbb6;
  text-shadow: 0 1px 5px #190d23;
}
@keyframes companion-float {
  0%,100% { transform: translateY(1px) rotate(-2deg); }
  50% { transform: translateY(-4px) rotate(2deg); }
}
@media (hover:hover) {
  .cell:not(:disabled):not(.empty):hover {
    transform: translateY(-3px);
    border-color: #e8c89188;
  }
  .tabs button:hover {
    background: #e5c59612;
  }
}
@media (max-width:1050px) {
  .layout { grid-template-columns: minmax(0,1fr) 330px; }
  .world-postcard { display: none; }
}
@media (max-width:700px) {
  .world-backdrop { background-position: left top; }
  .topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
  .identity h1 { font-size: 15px; }
  .identity small { font-size: 7px; }
  main { padding: 12px 12px 20px; }
  .overview { padding: 15px 13px; gap: 6px; border-radius: 22px; align-items: center; }
  .welcome { gap: 6px; }
  .companion { width: 46px; height: 63px; }
  .overview h2 { font-size: 22px; margin: 4px 0; line-height: 1.15; }
  .eyebrow { font-size: 7px; letter-spacing: .07em; }
  .overview p { font-size: 9px; line-height: 1.5; }
  .wallet { min-width: 96px; padding: 10px 8px; }
  .wallet strong { font-size: 24px; }
  .wallet span { font-size: 7px; }
  .wallet small { font-size: 8px; }
  #shards { font-size: 9px; }
  .layout { grid-template-columns: 1fr; gap: 17px; }
  .play-panel { padding: 13px; border-radius: 22px; }
  .board { padding: 8px; gap: 6px; border-radius: 16px; }
  .cell { border-radius: 11px; }
  .cell .rank { right: 3px; bottom: 3px; left: auto; font-size: 8px; padding: 0 3px; }
  .field-header { font-size: 9px; margin-bottom: 11px; }
  .spawn-button { min-height: 48px; font-size: 13px; }
  .spawn-button small { margin-left: 3px; font-size: 9px; }
  .extra-actions button { font-size: 10px; }
  .selection { font-size: 10px; }
  .side-panel { border-radius: 22px; }
  .tabs { position: static; background: #2b242c66; padding: 8px 11px 12px; }
  .tabs button { flex-basis: 29%; font-size: 10px; min-height: 36px; }
  .tab-icon { font-size: 12px; margin-right: 4px; }
  .notebook-heading { padding-top: 14px; }
  .panel-content { max-height: none; padding: 16px; }
}
@media (max-width:370px) {
  .companion { display: none; }
  .overview h2 { font-size: 21px; }
}
@media (prefers-reduced-motion:reduce) {
  .companion img { animation: none; }
  .cell.chain-bloom { animation: none; }
}
