:root {
  color-scheme: light;
  font-family:
    Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #23313d;
  --muted: #677988;
  --panel: rgba(255, 255, 255, 0.76);
  --line: rgba(80, 116, 130, 0.2);
  --accent: #2f9f91;
  --accent-dark: #1d756b;
  --warm: #f5b85b;
  --danger: #b85d5d;
  --sky-glow: rgba(255, 241, 178, 0.8);
  --sky-start: #bde9ef;
  --sky-mid: #dbf4df;
  --sky-end: #fff2c6;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
}

body {
  background:
    radial-gradient(circle at 78% 18%, var(--sky-glow), transparent 30%),
    linear-gradient(160deg, var(--sky-start) 0%, var(--sky-mid) 48%, var(--sky-end) 100%);
  transition: background 800ms ease;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.hidden {
  display: none !important;
}

#app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game-view {
  position: absolute;
  inset: 0;
}

#game-view canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  position: absolute;
  top: 24px;
  left: 24px;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(51, 89, 105, 0.18);
  backdrop-filter: blur(18px);
  scrollbar-width: thin;
  scrollbar-color: rgba(47, 159, 145, 0.42) transparent;
}

#hud::-webkit-scrollbar {
  width: 8px;
}

#hud::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(47, 159, 145, 0.34);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 26px;
}

.subtitle,
.auth-copy {
  margin: 8px 0 0;
  color: var(--muted);
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.ghost-button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.52);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.status-grid .stat:last-child {
  grid-column: 1 / -1;
}

.stat {
  min-height: 74px;
  padding: 12px;
  border: 1px solid rgba(47, 159, 145, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 21px;
  line-height: 1;
}

.meter-group {
  margin-top: 18px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.meter {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(35, 49, 61, 0.12);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--warm), var(--accent));
  transition: width 200ms ease;
}

#feedButton,
.auth-actions button {
  min-height: 46px;
  border-radius: 8px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 12px 24px rgba(47, 159, 145, 0.26);
}

#feedButton {
  width: 100%;
  margin-top: 20px;
}

.environment-panel,
.system-panel,
.shop-panel,
.inventory-panel,
.job-panel,
.daily-panel,
.bottle-panel {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(47, 159, 145, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

.gameplay-tabs {
  position: sticky;
  top: -22px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
  padding: 8px 0;
  background: rgba(235, 247, 245, 0.78);
  backdrop-filter: blur(12px);
}

.bottle-card {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid rgba(131, 167, 255, 0.34);
  border-radius: 8px;
  background: rgba(238, 244, 255, 0.68);
}

.bottle-card p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.bottle-panel textarea {
  width: 100%;
  min-height: 78px;
  resize: vertical;
  padding: 10px;
  border: 1px solid rgba(80, 116, 130, 0.22);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  outline: none;
}

.bottle-panel textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 159, 145, 0.14);
}

.bottle-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.bottle-actions button {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  color: white;
  font-size: 12px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.bottle-actions button:first-child {
  background: linear-gradient(135deg, #83a7ff, #5376d8);
}

.tab-button {
  min-height: 38px;
  border: 1px solid rgba(47, 159, 145, 0.18);
  border-radius: 8px;
  color: var(--accent-dark);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.56);
}

.tab-button.active {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 20px rgba(47, 159, 145, 0.18);
}

.gameplay-panel {
  display: none;
}

.gameplay-panel.active {
  display: block;
}

.environment-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.environment-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.system-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.system-panel strong,
.shop-heading strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.system-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.system-panel .secondary-button {
  min-width: 86px;
  min-height: 38px;
  border-radius: 8px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, var(--warm), #db8e37);
}

.shop-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.building-shop {
  display: grid;
  gap: 8px;
}

.building-card,
.job-card {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 8px 10px;
  border: 1px solid rgba(80, 116, 130, 0.18);
  border-radius: 8px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.58);
}

.building-card:disabled {
  cursor: default;
}

.building-swatch {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(35, 49, 61, 0.12);
}

.building-info {
  display: grid;
  gap: 2px;
}

.building-info strong {
  font-size: 13px;
}

.building-info small {
  color: var(--muted);
  font-size: 12px;
}

.building-cost {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.material-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.material-grid span {
  min-height: 42px;
  padding: 8px;
  border: 1px solid rgba(80, 116, 130, 0.16);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.5);
}

.material-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 16px;
}

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

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

.job-card {
  grid-template-columns: 1fr auto;
}

.job-card strong,
.active-job strong {
  display: block;
  font-size: 13px;
}

.job-card small,
.active-job small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.job-card .job-reward {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.active-job {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid rgba(245, 184, 91, 0.34);
  border-radius: 8px;
  background: rgba(255, 247, 224, 0.66);
}

.active-job button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, var(--warm), #db8e37);
}

.daily-quest {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid rgba(80, 116, 130, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.daily-quest.complete {
  border-color: rgba(47, 159, 145, 0.32);
  background: rgba(235, 255, 248, 0.68);
}

.daily-quest.claimed {
  opacity: 0.7;
}

.daily-quest strong {
  display: block;
  font-size: 13px;
}

.daily-quest small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.daily-quest button {
  min-height: 34px;
  min-width: 64px;
  padding: 0 10px;
  border-radius: 8px;
  color: white;
  font-size: 12px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

#message,
#authMessage {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(229, 247, 238, 0.44);
  backdrop-filter: blur(5px);
}

.auth-card {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 24px 70px rgba(51, 89, 105, 0.22);
}

.auth-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
  padding: 5px;
  border: 1px solid rgba(47, 159, 145, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
}

.auth-mode button {
  min-height: 40px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 800;
  background: transparent;
}

.auth-mode button.active {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 10px 20px rgba(47, 159, 145, 0.22);
}

#authForm {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

#authForm label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

#authForm input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(80, 116, 130, 0.26);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
}

#authForm input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 159, 145, 0.14);
}

.auth-actions {
  display: grid;
}

.auth-actions button {
  width: 100%;
}

@media (max-width: 720px) {
  #hud {
    top: auto;
    right: 16px;
    bottom: 16px;
    left: 16px;
    width: auto;
    max-height: min(58vh, 560px);
    padding: 16px;
  }

  .gameplay-tabs {
    top: -16px;
  }

  h1 {
    font-size: 24px;
  }

  .status-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .status-grid .stat:last-child {
    grid-column: 1 / -1;
  }

  .stat {
    min-height: 66px;
    padding: 9px;
  }

  .stat strong {
    font-size: 16px;
  }
}

@media (max-width: 520px) {
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-card {
    padding: 20px;
  }
}
