:root {
  --teal:        #00b7c4;   /* matches the base / money sprite */
  --teal-dark:   #067c85;
  --ink:         #14232b;
  --paper:       #ffffff;
  --panel:       #eef4f5;
  --panel-line:  #c8d8db;
  --btn:         #f4f8f9;
  --btn-line:    #9db4b8;
  --gold:        #d9a400;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #0f2a30;
  color: var(--ink);
  font-family: Tahoma, Verdana, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 14px 40px;
  min-height: 100vh;
  background: linear-gradient(#12333b, #0f2a30);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.wordmark {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .01em;
  color: #eafbfd;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

/* ---------- Title splash (overlays the game panel only) ---------- */
.splash {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity .35s ease;
}
.splash.hidden {
  opacity: 0;
  pointer-events: none;
}
.splash-img {
  height: 100%;          /* fill the panel top-to-bottom */
  width: auto;
  max-width: 100%;
  image-rendering: auto;
}
.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #bfe6ea;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.field select,
.field input[type="file"] {
  font: inherit;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
  padding: 4px 6px;
  border: 1px solid var(--btn-line);
  border-radius: 4px;
  background: var(--btn);
  color: var(--ink);
  max-width: 220px;
}
.file-field input { max-width: 190px; }

/* ---------- Playfield ---------- */
.playfield {
  position: relative;   /* positioning context for the splash overlay */
  background: var(--paper);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 12px 12px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  text-align: center;
}
.room-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  min-height: 22px;
}
.room-title.done { color: var(--teal-dark); }
.room-record {
  font-size: 12px;
  color: #6c8288;
  min-height: 16px;
  margin-bottom: 6px;
}

.board-wrap {
  position: relative;
  display: inline-block;
  min-width: 160px;
  min-height: 160px;
  background: #fff;
}
#board {
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.message {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--gold);
  font-weight: 700;
  font-size: 20px;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
  pointer-events: none;
  white-space: nowrap;
}
.start-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink);
  padding: 20px;
}
.start-screen .hint { color: #6c8288; font-size: 13px; }
.start-screen.hidden { display: none; }

.stats {
  margin-top: 10px;
  font-family: "Lucida Console", Consolas, monospace;
  font-size: 15px;
  letter-spacing: .02em;
  color: var(--ink);
  white-space: pre;
}

/* ---------- D-pad ---------- */
.dpad {
  margin: 14px auto 2px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.dpad-mid { display: flex; gap: 6px; }
.pad {
  width: 52px;
  height: 46px;
  font-size: 18px;
  border: 1px solid var(--btn-line);
  border-radius: 6px;
  background: var(--btn);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.pad:active { background: var(--teal); color: #fff; }

/* ---------- Controls ---------- */
.controls {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.control-group {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 8px 10px;
}
.group-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--teal-dark);
  font-weight: 700;
  margin-bottom: 6px;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.controls button {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--btn-line);
  border-radius: 5px;
  background: var(--btn);
  color: var(--ink);
  cursor: pointer;
}
.controls button:hover { background: #e6eff0; }
.controls button:active { background: var(--teal); color: #fff; border-color: var(--teal-dark); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  margin-left: 4px;
  color: var(--ink);
  cursor: pointer;
}

/* ---------- Rules ---------- */
.rules {
  margin-top: 18px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  padding: 12px 16px;
  color: #dbecef;
  font-size: 13px;
  line-height: 1.6;
}
.rules h2 { margin: 0 0 6px; font-size: 15px; color: #fff; }
.rules p { margin: 6px 0; }
.inline-sprite {
  width: 18px;
  height: 18px;
  vertical-align: -4px;
  image-rendering: pixelated;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.credit { color: #9fc2c7; font-size: 12px; margin-top: 10px; }

@media (max-width: 520px) {
  .logo { height: 64px; }
  .topbar { justify-content: center; }
  .controls button { flex: 1 1 auto; }
}
