/* style.css */
:root {
  color-scheme: dark;
  --ink: #f7f0df;
  --muted: #aeb8bb;
  --panel: rgba(17, 28, 39, .94);
  --panel-soft: rgba(30, 44, 57, .82);
  --line: rgba(255, 255, 255, .12);
  --gold: #f5c76b;
}

:root[data-theme="light"] {
  color-scheme: light;
  --ink: #16222b;
  --muted: #546269;
  --panel: rgba(249, 245, 234, .96);
  --panel-soft: rgba(232, 241, 238, .94);
  --line: rgba(20, 35, 40, .14);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --ink: #16222b;
    --muted: #546269;
    --panel: rgba(249, 245, 234, .96);
    --panel-soft: rgba(232, 241, 238, .94);
    --line: rgba(20, 35, 40, .14);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
  background: #102330;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  transition: .18s ease;
}

button:hover:not(:disabled) {
  background: var(--gold);
  color: #17212a;
  transform: translateY(-1px);
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

#app,
#game-shell {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

#game-shell {
  display: flex;
  flex-direction: column;
}

#hud {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  width: 100%;
  padding: 17px clamp(15px, 3vw, 38px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(8, 20, 29, .75), transparent);
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: .92;
  letter-spacing: .16em;
  text-shadow: 0 2px 12px #102330;
}

.brand strong {
  color: var(--gold);
  font-size: clamp(15px, 2vw, 22px);
}

.brand span {
  margin-top: 5px;
  color: var(--ink);
  font-size: 9px;
  letter-spacing: .38em;
}

.stats {
  display: flex;
  gap: clamp(10px, 3vw, 28px);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .12em;
}

.stats b {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 17px;
  letter-spacing: 0;
}

#scene-wrap {
  position: relative;
  flex: 1;
  min-height: 540px;
  overflow: hidden;
  background: #238ca5;
}

#scene {
  position: absolute;
  inset: 0;
  background: linear-gradient(#68b4c8, #238ca5);
}

#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.message {
  position: absolute;
  top: 82px;
  left: 50%;
  max-width: min(90%, 500px);
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: rgba(12, 25, 35, .82);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  font-size: 12px;
  transform: translate(-50%, -12px);
  transition: .3s;
}

.message.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#controls {
  position: absolute;
  z-index: 5;
  bottom: 18px;
  left: 0;
  width: 100%;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
}

.control-cluster,
.action-buttons {
  pointer-events: auto;
}

.control-cluster {
  display: grid;
  gap: 4px;
  text-align: center;
}

.control-cluster > div {
  display: flex;
  gap: 4px;
}

.touch {
  width: 58px;
  min-height: 42px;
  padding: 0 5px;
  background: rgba(12, 30, 40, .74);
}

.touch.danger {
  color: #ffd4a2;
  border-color: rgba(245, 199, 107, .4);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

#side-panel {
  position: absolute;
  z-index: 7;
  top: 0;
  right: 0;
  width: min(430px, 94vw);
  height: 100%;
  padding: clamp(20px, 4vw, 38px);
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -20px 0 50px rgba(0, 0, 0, .22);
  transform: translateX(102%);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}

#side-panel.open {
  transform: translateX(0);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 28px;
}

.eyebrow {
  color: var(--gold);
  font-size: 9px;
  letter-spacing: .2em;
  font-weight: 800;
}

h1 {
  margin: 8px 0 0;
  font: 600 clamp(26px, 5vw, 40px) / 1.05 Georgia, serif;
}

h2 {
  color: var(--gold);
  font-size: 11px;
  letter-spacing: .16em;
}

p,
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

.card {
  display: flex;
  gap: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-soft);
}

.card img {
  width: 48px;
  height: 48px;
  padding: 5px;
  border-radius: 8px;
  background: #e8c98b;
  object-fit: contain;
}

.card strong {
  font-size: 14px;
}

.card p {
  margin: 5px 0 0;
  font-size: 12px;
  line-height: 1.45;
}

.tips {
  margin-top: 28px;
}

.tips p {
  margin: 8px 0;
}

.tips b {
  color: var(--ink);
}

.event-log {
  margin-top: 28px;
  border-top: 1px solid var(--line);
}

.event-log div {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.market-header,
.market-row {
  display: grid;
  grid-template-columns: 1.3fr .6fr .5fr 1fr;
  gap: 7px;
  align-items: center;
}

.market-header {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .12em;
}

.market-row {
  min-height: 66px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.market-row > span {
  color: var(--gold);
}

.market-actions {
  display: flex;
  gap: 4px;
}

.market-actions button {
  min-height: 34px;
  padding: 0 7px;
  font-size: 9px;
}

.port-footer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
}

.port-footer span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

@media (max-width: 600px) {
  #scene-wrap {
    min-height: 100vh;
  }

  #hud {
    align-items: start;
  }

  .stats {
    gap: 9px;
  }

  .stats span {
    font-size: 8px;
  }

  .stats b {
    font-size: 14px;
  }

  #controls {
    bottom: 12px;
  }

  .action-buttons button {
    min-height: 38px;
    padding: 0 8px;
    font-size: 9px;
  }

  .message {
    top: 75px;
  }
}
