/* Splashland — big, bright, easy to click */
:root {
  --sky1: #7ed6f5;
  --sky2: #4bb8e0;
  --deep: #0d4e6b;
  --panel: #ffffff;
  --ink: #123a4d;
  --sun: #ffd23f;
  --good: #23b26d;
  --bad: #e0483a;
  --shadow: 0 4px 0 rgba(9, 60, 84, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Baloo 2", "Nunito", "Avenir Next Rounded", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 14px, rgba(0, 0, 0, 0.03) 14px 28px),
    radial-gradient(120% 90% at 50% 0%, #8fdcef 0%, #46b2d6 55%, #2b8fba 100%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body { display: block; position: relative; }
#app { display: flex; flex-direction: column; height: 100%; position: relative; }
body.placing #stage { cursor: copy; }

/* ------------------------------------------------------------- top bar --- */
#top {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 3px solid rgba(13, 78, 107, 0.18);
  flex-wrap: wrap;
}

.brand {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--deep);
  margin-right: 4px;
}
.brand span { background: linear-gradient(180deg, #159fd4, #0d6f97); -webkit-background-clip: text; background-clip: text; color: transparent; }

.stat {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #eef7fb;
  border: 2px solid #cfe7f2;
  border-radius: 12px;
  padding: 4px 9px;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
}
.stat i { font-style: normal; font-size: 15px; }
.stat.money { background: #fff6da; border-color: #f3dc9a; }
.stat.stars { font-size: 17px; color: #f0a90d; letter-spacing: 1px; background: #fff9e8; border-color: #f5e2ac; }

.ticketbox button, .speeds button, .icon-btn {
  border: none;
  border-radius: 9px;
  background: #d8ecf6;
  color: var(--deep);
  font-weight: 900;
  font-size: 15px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  line-height: 1;
}
.ticketbox button:hover, .speeds button:hover, .icon-btn:hover { background: #bfe1f2; }
.ticketbox button:active { transform: translateY(1px); }

.daybox { flex-direction: column; align-items: flex-start; gap: 1px; padding: 4px 11px; }
.daybox span { font-size: 13px; line-height: 1.15; }
.daybox .track { width: 76px; height: 5px; background: #cfe7f2; border-radius: 3px; overflow: hidden; margin-top: 2px; }
#daybar { height: 100%; width: 0; background: linear-gradient(90deg, #ffd23f, #ff9d3f); }

.spacer { flex: 1; }

.speeds { display: flex; gap: 4px; }
.speeds button { width: auto; padding: 0 7px; height: 28px; font-size: 11px; }
.speeds button.on { background: var(--sun); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12); }
.icon-btn { width: 30px; height: 28px; font-size: 14px; background: #e8f4fa; }

/* --------------------------------------------------------------- board --- */
#stagewrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  min-height: 0;
}

#board {
  position: relative;
  /* main.js sizes this to whatever space is actually left, keeping 880x600 */
  width: 320px;
  max-width: 100%;
}

#stage {
  display: block;
  width: 100%;
  height: auto;
  touch-action: manipulation;
  border-radius: 16px;
  border: 4px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 12px 30px rgba(6, 45, 66, 0.35);
  background: #8fd66b;
  cursor: pointer;
}

.overlay {
  position: absolute;
  pointer-events: none;
  border-radius: 12px;
  padding: 7px 12px;
  font-weight: 800;
}

#goalbar {
  display: flex;
  justify-content: center;
  padding: 6px 12px 0;
}
#goal {
  background: rgba(255, 255, 255, 0.93);
  border-radius: 14px;
  padding: 5px 16px;
  box-shadow: var(--shadow);
  max-width: 900px;
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
#goal b { font-size: 15px; font-weight: 800; }
#goal small { font-weight: 600; opacity: 0.72; font-size: 12px; }

#warn {
  right: 12px;
  top: 12px;
  background: rgba(255, 236, 179, 0.96);
  border: 2px solid #f0c14b;
  font-size: 14px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s, transform 0.2s;
}
#warn.show { opacity: 1; transform: none; }

#toasts {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 90%;
}
.toast {
  background: rgba(10, 50, 70, 0.9);
  color: #fff;
  border-radius: 14px;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  animation: pop 0.25s ease-out;
  transition: opacity 0.6s, transform 0.6s;
}
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes pop { from { transform: scale(0.85) translateY(6px); opacity: 0; } }

/* ------------------------------------------------------------- toolbar --- */
#toolbar {
  position: relative;
  background: rgba(255, 255, 255, 0.94);
  border-top: 3px solid rgba(13, 78, 107, 0.18);
  padding: 8px 12px 10px;
}

#tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid #cfe7f2;
  background: #eef7fb;
  border-radius: 12px 12px 4px 4px;
  padding: 6px 12px;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.tab .ic { font-size: 17px; }
.tab.on { background: var(--sun); border-color: #e8b400; }
.tab.sell { margin-left: auto; background: #ffe4e0; border-color: #f3b8ae; }
.tab.sell.on { background: #ff7a68; color: #fff; border-color: #d94a37; }

#items { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 2px; min-height: 78px; align-items: stretch; }

.item {
  flex: 0 0 auto;
  width: 104px;
  border: 3px solid #d6ecf6;
  background: #fff;
  border-radius: 14px;
  padding: 6px 4px 5px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  box-shadow: 0 3px 0 rgba(9, 60, 84, 0.14);
  transition: transform 0.08s;
}
.item:hover { transform: translateY(-2px); border-color: #8ed3ee; }
.item:active { transform: translateY(1px); }
.item .thumb { display: block; margin: 0 auto 1px; }
.item .nm { font-size: 12px; font-weight: 800; text-align: center; line-height: 1.1; }
.item .pr { font-size: 12px; font-weight: 800; color: var(--good); }
.item.on { border-color: var(--sun); background: #fffaea; box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.5); }
.item.poor .pr { color: var(--bad); }
.item.poor { opacity: 0.62; }
.item.locked { opacity: 0.55; filter: grayscale(0.6); }
.item.locked .pr { color: #8899a3; }
.item.flyer { background: #fff2f6; border-color: #ffc9db; }

.staffrow {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fff;
  border: 3px solid #d6ecf6;
  border-radius: 14px;
  padding: 7px 12px;
  box-shadow: 0 3px 0 rgba(9, 60, 84, 0.14);
}
.staffrow .ic { font-size: 26px; }
.staffrow .txt b { display: block; font-size: 14px; }
.staffrow .txt small { opacity: 0.7; font-weight: 700; }
.pmb { display: flex; align-items: center; gap: 5px; }
.pmb button {
  width: 28px; height: 28px; border: none; border-radius: 9px;
  background: #d8ecf6; font-weight: 900; font-size: 16px; cursor: pointer; color: var(--deep);
}
.pmb button:hover { background: #bfe1f2; }
.pmb .cnt { font-weight: 900; min-width: 16px; text-align: center; font-size: 16px; }

.note {
  flex: 0 0 auto;
  align-self: center;
  max-width: 300px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.8;
  background: #f4fbff;
  border-radius: 12px;
  padding: 8px 12px;
  line-height: 1.35;
}

#tip {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 100%;
  margin-bottom: 6px;
  background: rgba(10, 50, 70, 0.92);
  color: #fff;
  padding: 7px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
#tip.show { opacity: 1; }

/* --------------------------------------------------------------- modal --- */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 45, 66, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}
#modal.show { display: flex; }
#modal-box {
  background: #fff;
  border-radius: 22px;
  padding: 22px 26px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  animation: pop 0.25s ease-out;
  max-height: 90vh;
  overflow: auto;
}
#modal h2 { margin: 0 0 10px; font-size: 24px; color: var(--deep); }
#modal p { line-height: 1.45; margin: 8px 0; }
#modal .small { font-size: 13px; opacity: 0.7; }
#modal .how { margin: 10px 0 4px; padding-left: 20px; line-height: 1.5; }
#modal .how li { margin-bottom: 6px; }
#modal .bad { color: var(--bad); font-weight: 700; }

.sheet { background: #f2f9fc; border-radius: 14px; padding: 8px 14px; margin: 10px 0; }
.srow { display: flex; justify-content: space-between; padding: 4px 0; font-weight: 700; font-size: 15px; }
.srow + .srow { border-top: 1px dashed #cfe2ea; }
.srow.good b { color: var(--good); }
.srow.bad b { color: var(--bad); }

/* difficulty picker on the welcome screen */
.pickline { font-weight: 800; margin: 14px 0 6px; }
.difficulty { display: flex; flex-direction: column; gap: 8px; }

.diff-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 3px solid #d6ecf6;
  border-radius: 16px;
  background: #fff;
  padding: 10px 14px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(9, 60, 84, 0.14);
  transition: transform 0.08s, border-color 0.12s;
}
.diff-btn:hover { transform: translateY(-2px); }
.diff-btn:active { transform: translateY(1px); }
.diff-btn .ic { font-size: 28px; line-height: 1; }
.diff-btn .txt { flex: 1; }
.diff-btn .txt b { display: block; font-size: 17px; }
.diff-btn .txt small { display: block; font-weight: 600; opacity: 0.72; font-size: 12px; line-height: 1.3; }
.diff-btn .cash { font-weight: 900; font-size: 15px; text-align: right; white-space: nowrap; }
.diff-btn .cash small { display: block; font-weight: 700; font-size: 10px; opacity: 0.6; }
.diff-btn.easy { border-color: #a7e0b4; background: #f4fdf6; }
.diff-btn.easy:hover { border-color: #5cc07a; }
.diff-btn.medium { border-color: #9fd4ee; background: #f3fbff; }
.diff-btn.medium:hover { border-color: #3ba7d8; }
.diff-btn.hard { border-color: #f3b8ae; background: #fff5f3; }
.diff-btn.hard:hover { border-color: #e0644f; }

.diffchip { background: #f6f1ff; border-color: #ded0f5; }

button.big {
  width: 100%;
  margin-top: 12px;
  border: none;
  border-radius: 16px;
  padding: 14px;
  font: inherit;
  font-size: 19px;
  font-weight: 900;
  color: #08384f;
  background: linear-gradient(180deg, #ffd85e, #ffb524);
  box-shadow: 0 4px 0 #d98f0d;
  cursor: pointer;
}
button.big:active { transform: translateY(2px); box-shadow: 0 2px 0 #d98f0d; }

@media (max-width: 1060px) {
  .brand span { display: none; }
}

/* Phones. The park is a landscape shape, so every pixel of chrome comes
   straight out of the play area — squeeze the header hard. */
#rotate-hint { display: none; }

@media (max-width: 760px), (max-height: 520px) {
  #top { gap: 4px; padding: 4px 6px; }
  .brand { font-size: 18px; margin-right: 0; }
  .stat { font-size: 12px; padding: 2px 6px; border-radius: 9px; gap: 3px; border-width: 1.5px; }
  .stat i { font-size: 12px; }
  .stat.stars { font-size: 13px; letter-spacing: 0; }
  .diffchip { font-size: 11px; }
  .daybox { padding: 2px 6px; }
  .daybox .track { width: 48px; }
  .daybox span { font-size: 10px; }
  .ticketbox button { width: 21px; height: 21px; font-size: 13px; }
  .speeds { gap: 2px; }
  .speeds button { padding: 0 5px; height: 23px; font-size: 9px; }
  .icon-btn { width: 25px; height: 23px; font-size: 12px; }
  .spacer { display: none; }

  #goalbar { padding: 3px 8px 0; }
  #goal { padding: 3px 10px; gap: 6px; border-radius: 10px; }
  #goal b { font-size: 12px; }
  #goal small { display: none; }

  #stagewrap { padding: 5px; }
  #toolbar { padding: 4px 7px 6px; }
  #tabs { gap: 4px; padding-bottom: 4px; }
  .tab { padding: 3px 8px; font-size: 11px; border-width: 2px; }
  .tab .ic { font-size: 13px; }
  #items { gap: 5px; min-height: 0; padding: 2px 0 0; }
  .item { width: 72px; padding: 3px 2px 2px; border-width: 2px; border-radius: 10px; }
  .item .thumb { width: 38px !important; height: 32px !important; }
  .item .nm { font-size: 9px; }
  .item .pr { font-size: 10px; }
  .staffrow { padding: 5px 9px; }
  .note { font-size: 11px; padding: 6px 9px; }
  #tip { display: none; }
}

/* A phone held sideways: only ~375px of height exists, and the toolbar was
   eating half of it. Drop to icon-only tabs and unlabelled item cards. */
/* Sideways on a phone there are only ~375px of height, and the header plus
   toolbar were eating 44% of it. Float the header over the park instead. */
/* Wide and short (a phone held sideways, or a portrait phone with the app
   turned): chrome belongs down the side, not across the bottom, or it eats
   the one dimension the park needs. */
@media (max-height: 520px), (max-width: 760px) and (orientation: portrait) {
  #app { flex-direction: row; }

  #toolbar {
    order: -1;
    width: 94px;
    flex: 0 0 94px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-top: none;
    border-right: 3px solid rgba(13, 78, 107, 0.18);
    padding: 4px 5px;
    overflow: hidden;
  }
  #tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    overflow: visible;
    padding: 0 0 4px;
    flex: 0 0 auto;
  }
  .tab { padding: 5px 0; justify-content: center; border-radius: 8px; }
  .tab.sell { margin-left: 0; }
  #items {
    flex-direction: column;
    align-items: stretch;
    overflow-y: auto;
    overflow-x: hidden;
    gap: 4px;
    padding: 2px 0;
    flex: 1 1 auto;
  }
  .item { width: auto; }
  .staffrow { width: auto; }

  #stagewrap { flex: 1 1 auto; min-width: 0; }

  #top {
    position: absolute;
    z-index: 5;
    top: 4px; left: 100px; right: 6px;
    background: rgba(255, 255, 255, 0.88);
    border: none;
    border-radius: 12px;
    padding: 3px 7px;
    box-shadow: 0 2px 6px rgba(9, 60, 84, 0.18);
  }
  #goalbar { display: none; }
  #toolbar { padding: 3px 6px 4px; }
  #stagewrap { padding: 4px; }
  #tabs { padding-bottom: 3px; }
  .tab { padding: 3px 7px; }
  .tab span:not(.ic) { display: none; }
  .tab.sell span:not(.ic) { display: inline; }
  .item { width: 58px; padding: 2px 2px 1px; }
  .item .thumb { width: 34px !important; height: 28px !important; }
  .item .nm { display: none; }
  .item .pr { font-size: 10px; }
  .staffrow .txt small { display: none; }
  .note { display: none; }
}

/* A portrait phone: turn the entire interface a quarter turn so that when the
   player turns the device the game is upright and fills the screen. Works
   whether or not the phone's rotation lock is on. */
@media (max-width: 760px) and (orientation: portrait) {
  #app {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vh;
    height: 100vw;
    width: 100dvh;
    height: 100dvw;
    transform-origin: top left;
    transform: rotate(90deg) translateY(-100%);
  }

  #rotate-hint {
    position: fixed;
    z-index: 40;
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
    display: block;
    text-align: center;
    font-size: 13px;
    font-weight: 900;
    color: #08384f;
    background: #ffd23f;
    padding: 6px 12px;
    border-radius: 10px;
    box-shadow: 0 2px 0 rgba(9, 60, 84, 0.2);
    transition: opacity 0.4s;
  }
  #rotate-hint.gone { opacity: 0; pointer-events: none; }
}
