html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; position: fixed; background: #7ed42f;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: rgba(0,0,0,0);
  -webkit-text-size-adjust: 100%;
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  touch-action: none; overscroll-behavior: none;
}
#app { position: fixed; left: 0; top: 0; right: 0; bottom: 0; }
#view { display: block; width: 100%; height: 100%; touch-action: none; }
.hidden { display: none !important; }
svg { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

#hud { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; }
#hud > * { pointer-events: none; }
#hud button { pointer-events: auto; }

.btn {
  position: relative; display: inline-block; vertical-align: middle;
  width: 60px; height: 60px; width: min(62px, 15.2vw); height: min(62px, 15.2vw);
  border-radius: 50%; border: 3px solid #fff; padding: 0; margin: 0;
  box-shadow: 0 4px 0 rgba(0,0,0,0.25), 0 6px 10px rgba(0,0,0,0.2);
  background: #8895a7; color: #fff; outline: none; overflow: hidden;
  -webkit-appearance: none; appearance: none; touch-action: manipulation;
  transition: transform 0.08s;
}
.btn svg { width: 62%; height: 62%; position: absolute; left: 19%; top: 19%; stroke-width: 2.4; }
.btn:active, .btn.press { transform: translateY(3px) scale(0.94); box-shadow: 0 1px 0 rgba(0,0,0,0.25); }
.btn.small { width: 46px; height: 46px; width: min(48px, 11.6vw); height: min(48px, 11.6vw); }
.btn.blue { background: #3d8bff; } .btn.green { background: #34c759; }
.btn.purple { background: #a35cf2; } .btn.orange { background: #ff9f1a; }
.btn.red { background: #ff5a5a; } .btn.white { background: #ffffff; }
.btn.white svg { stroke: #3d5a80; }
.btn.pulse { animation: pulse 0.5s 2; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.22); } }
.btn.shake { animation: shake 0.4s; }
@keyframes shake { 0%,100% { transform: translateX(0) } 20% { transform: translateX(-6px) } 40% { transform: translateX(6px) } 60% { transform: translateX(-4px) } 80% { transform: translateX(4px) } }
#trashFill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: #b3001b; opacity: 0.7; }

#topLeft { position: absolute; left: 10px; top: 10px; left: calc(10px + env(safe-area-inset-left)); top: calc(10px + env(safe-area-inset-top)); }
#topLeft .btn { display: block; margin-bottom: 10px; }
#topLeft .btn.small { margin-left: 7px; }
#topRight { position: absolute; right: 10px; top: 10px; right: calc(10px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top)); }

#bottom {
  position: absolute; left: 0; right: 0; bottom: 0; text-align: center; white-space: nowrap;
  padding: 0 6px 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  padding-left: calc(6px + env(safe-area-inset-left)); padding-right: calc(6px + env(safe-area-inset-right));
}
#bottom > .btn, #bottom > #seg { margin: 0 3px; }
#seg { display: inline-block; vertical-align: middle; }
#seg .btn { border-radius: 0; margin: 0; background: #b8c2cf; }
#seg .btn:first-child { border-radius: 31px 0 0 31px; border-right-width: 1px; }
#seg .btn:last-child { border-radius: 0 31px 31px 0; border-left-width: 1px; }
#seg .btn.on-draw { background: #1f6bff; }
#seg .btn.on-move { background: #ff8a00; }
#seg .btn.active-seg { box-shadow: 0 0 0 3px #fff, 0 4px 0 rgba(0,0,0,0.25); z-index: 2; }
.pips { position: absolute; left: 0; right: 0; bottom: 5px; text-align: center; line-height: 0; }
.pips i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin: 0 1.5px; background: rgba(255,255,255,0.45); }
.pips i.on { background: #fff; }
.btn.purple svg { top: 12%; height: 56%; }

#chip { position: absolute; left: 50%; bottom: 100px; bottom: calc(100px + env(safe-area-inset-bottom)); margin-left: -70px; width: 140px; text-align: center; background: rgba(255,255,255,0.92); border-radius: 40px; padding: 4px 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.25); height: 56px; pointer-events: none; }
#chip img { height: 52px; width: 52px; vertical-align: middle; margin-right: 8px; }
#chip .btn { vertical-align: middle; pointer-events: auto; }

#hint { position: absolute; left: 50%; top: 40%; width: 220px; height: 132px; margin-left: -110px; margin-top: -66px; pointer-events: none; opacity: 0.9; }
#hint path, #hint circle { stroke: #2b5dff; }

.modal { position: absolute; left: 0; top: 0; right: 0; bottom: 0; background: rgba(20, 40, 10, 0.5); z-index: 20; text-align: center; }
.modal:before { content: ""; display: inline-block; height: 100%; vertical-align: middle; }
.card { display: inline-block; vertical-align: middle; width: 88%; max-width: 440px; background: #fffbea; border-radius: 26px; border: 4px solid #fff; box-shadow: 0 10px 30px rgba(0,0,0,0.35); padding: 12px 12px 14px; text-align: center; }
.card.small { max-width: 360px; }
.title { font-size: 22px; font-weight: 800; color: #3a4a2a; padding: 4px 0 10px; letter-spacing: 0.3px; }
.scroll { max-height: 56vh; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 2px 4px; }
.row { display: block; background: #fff; border-radius: 18px; margin: 0 0 10px; padding: 6px 8px; border: 3px solid #e8e2c4; text-align: left; cursor: pointer; touch-action: manipulation; }
.row:active { background: #ffe9a8; }
.row img { display: inline-block; vertical-align: middle; width: 200px; height: 82px; object-fit: contain; }
.row .nm { display: inline-block; vertical-align: middle; font-size: 16px; font-weight: 700; color: #4a5a3a; margin-left: 6px; }
.foot { padding-top: 6px; }
.pill { display: inline-block; vertical-align: middle; border: 3px solid #fff; border-radius: 40px; height: 52px; min-width: 128px; margin: 4px 6px 0; padding: 0 16px 0 10px; font-size: 18px; font-weight: 800; color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,0.25); touch-action: manipulation; -webkit-appearance: none; outline: none; }
.pill svg { width: 28px; height: 28px; vertical-align: middle; margin-right: 4px; stroke-width: 2.6; }
.pill span { vertical-align: middle; }
.pill.red { background: #ff5a5a; } .pill.blue { background: #3d8bff; } .pill.green { background: #34c759; }
.pill:active { transform: translateY(3px); box-shadow: none; }

.sheet { position: absolute; left: 8px; right: 8px; bottom: 90px; bottom: calc(90px + env(safe-area-inset-bottom)); background: rgba(255,251,234,0.96); border-radius: 24px; border: 4px solid #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.3); padding: 8px 6px 4px; z-index: 15; max-width: 520px; margin: 0 auto; }
.hrow { white-space: nowrap; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-x; padding: 4px 2px 8px; }
.item { display: inline-block; vertical-align: middle; width: 76px; height: 76px; margin: 0 4px; background: #fff; border-radius: 18px; border: 3px solid #e8e2c4; touch-action: manipulation; position: relative; }
.item img { width: 66px; height: 66px; display: block; margin: 2px auto 0; }
.item:active { background: #ffe9a8; }
.item.dice { background: #34c759; border-color: #fff; }
.item.dice svg { width: 52px; height: 52px; margin: 8px; stroke-width: 2.2; }
.trayclose { position: absolute; right: -6px; top: -16px; width: 36px; height: 36px; border-radius: 50%; background: #ff5a5a; border: 3px solid #fff; padding: 0; z-index: 2; box-shadow: 0 3px 0 rgba(0,0,0,0.25); }
.trayclose svg { width: 20px; height: 20px; }

.menurow { padding: 4px 0 8px; }
.bigtoggle { width: 76px; height: 76px; border-radius: 22px; border: 4px solid #e8e2c4; background: #fff; margin: 0 6px; padding: 0; font-size: 36px; touch-action: manipulation; -webkit-appearance: none; outline: none; }
.bigtoggle.sel { background: #cfeeff; border-color: #3d8bff; }
.bigtoggle.off { opacity: 0.45; }
.bigtoggle:active { transform: scale(0.94); }
.em { display: inline-block; line-height: 1; font-size: 36px; }

@media (min-width: 600px) {
  .btn { width: 80px; height: 80px; }
  .btn.small { width: 60px; height: 60px; }
  #seg .btn:first-child { border-radius: 40px 0 0 40px; } #seg .btn:last-child { border-radius: 0 40px 40px 0; }
  #chip { bottom: 130px; }
  .sheet { bottom: 116px; }
}
@media (orientation: landscape) and (max-height: 450px) {
  .btn { width: 50px; height: 50px; } .btn.small { width: 42px; height: 42px; }
  #bottom { padding-bottom: 6px; }
  .scroll { max-height: calc(100vh - 150px); }
  .row img { width: 150px; height: 60px; }
  .row { margin-bottom: 6px; }
  .title { font-size: 18px; padding: 0 0 6px; }
  .pill { height: 44px; }
  .sheet { bottom: 66px; }
  #chip { bottom: 70px; }
}
@media (max-width: 380px) {
  .row { white-space: nowrap; padding: 4px 6px; }
  .row img { width: 156px; height: 64px; }
  .row .nm { font-size: 15px; margin-left: 2px; }
  .pill { min-width: 0; padding: 0 12px 0 8px; font-size: 16px; margin: 4px 3px 0; }
}

/* v2: speed buttons while following a train, three-row tray, menu extras */
#speedBox { position: absolute; right: 10px; top: 84px; right: calc(10px + env(safe-area-inset-right)); top: calc(84px + env(safe-area-inset-top)); }
#speedBox .btn { display: block; margin-bottom: 8px; margin-left: auto; }
#speedBox .em { font-size: 24px; line-height: 40px; }
.btn .em { position: absolute; left: 0; right: 0; top: 0; text-align: center; }
.item.water { background: #e4f6ff; border-color: #8fd3ff; }
.bigtoggle.viewbtn { width: 52px; height: 52px; border-radius: 40px; vertical-align: middle; margin: 4px 6px 0; }
.bigtoggle.viewbtn .em { font-size: 26px; }
.sheet { max-height: calc(100vh - 150px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 380px) { .item { width: 66px; height: 66px; margin: 0 3px; } .item img { width: 58px; height: 58px; } .item.dice svg { width: 44px; height: 44px; margin: 6px; } }
@media (orientation: landscape) and (max-height: 450px) { .item { width: 54px; height: 54px; } .item img { width: 46px; height: 46px; } .item.dice svg { width: 36px; height: 36px; margin: 6px; } .hrow { padding: 2px 2px 4px; } .sheet { max-height: calc(100vh - 130px); } }
