:root {
  --ink: #263a36;
  --cream: #fff9e9;
  --yellow: #f7dc69;
  --green: #78bf78;
  --pink: #f38a91;
  --blue: #75cbd3;
  --purple: #9a83d3;
  --shadow: 0 14px 35px rgba(43, 68, 59, .22);
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #game { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: #9bd9d3; user-select: none; -webkit-user-select: none; }
button { color: inherit; font: inherit; border: 0; cursor: pointer; }
button:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
#game { position: relative; isolation: isolate; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: none; }

.hud-top {
  position: absolute;
  z-index: 10;
  top: max(22px, env(safe-area-inset-top));
  left: max(25px, env(safe-area-inset-left));
  right: max(25px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  pointer-events: none;
}
.logo { display: flex; gap: 1px; color: var(--ink); text-decoration: none; font-weight: 1000; font-size: clamp(20px, 2.2vw, 32px); letter-spacing: -.08em; pointer-events: auto; filter: drop-shadow(0 2px 0 rgba(255,255,255,.45)); }
.logo span:nth-child(1) { color: #ee727d; transform: rotate(-7deg); }
.logo span:nth-child(2) { color: #f2c851; transform: translateY(2px) rotate(4deg); }
.logo span:nth-child(3) { color: #62b87b; transform: rotate(-2deg); }
.logo span:nth-child(4) { color: #718bce; transform: translateY(1px) rotate(6deg); }
.island-name { margin: 0 auto; padding: 7px 18px 8px; text-align: center; border-radius: 16px; color: #fff; background: rgba(35,59,54,.32); backdrop-filter: blur(10px); text-shadow: 0 1px 3px #27453f99; }
.island-name span { display: block; font-size: 8px; font-weight: 900; letter-spacing: .19em; opacity: .72; }
.island-name strong { display: block; margin-top: 1px; font-size: 12px; letter-spacing: .05em; }
.round-button, .reset-button { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--ink); background: rgba(255,249,233,.88); box-shadow: var(--shadow); pointer-events: auto; font-weight: 900; }
.round-button:hover, .reset-button:hover { transform: translateY(-2px) rotate(4deg); background: #fff; }

.bud-wheel {
  position: absolute;
  z-index: 11;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
  padding: 8px;
  border-radius: 25px;
  background: rgba(255,249,233,.72);
  box-shadow: 0 12px 40px rgba(48,77,67,.2), inset 0 1px 0 #fff9;
  backdrop-filter: blur(13px);
}
.bud-choice { position: relative; display: grid; grid-template-columns: 31px auto; grid-template-rows: 17px 12px; align-items: center; min-width: 76px; height: 50px; padding: 4px 12px 4px 7px; border-radius: 18px; background: transparent; transition: transform .18s ease, background .18s; }
.bud-choice:hover { transform: translateY(-3px); background: #fff8; }
.bud-choice.active { background: #fff; box-shadow: 0 6px 16px #39594e24; transform: translateY(-3px); }
.bud-choice i { grid-row: 1 / 3; position: relative; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 48% 52% 45% 55%; font-style: normal; }
.bud-choice i::before, .bud-choice i::after { content: ""; position: absolute; top: 9px; width: 4px; height: 5px; border-radius: 50%; background: var(--ink); }
.bud-choice i::before { left: 8px; }.bud-choice i::after { right: 8px; }
.bud-choice .all-icon { color: #fff; background: var(--ink); font-size: 11px; letter-spacing: -1px; }
.bud-choice .all-icon::before, .bud-choice .all-icon::after { display: none; }
.heavy-icon { background: var(--purple); transform: scaleY(.85); }
.heavy-icon::after { box-shadow: 0 8px 0 -1px #fff8; }
.sticky-icon { background: var(--green); transform: scaleX(.8) scaleY(1.08); }
.sticky-icon::after { box-shadow: 6px -8px 0 -1px var(--green); }
.bouncy-icon { background: var(--pink); box-shadow: inset 0 -4px 0 #d8627160; }
.spark-icon { color: #674f1c; background: var(--yellow); font-size: 16px; font-weight: 1000; }
.spark-icon::before, .spark-icon::after { display: none; }
.bud-choice span { align-self: end; font-size: 10px; font-weight: 900; }
.bud-choice b { align-self: start; font-size: 9px; opacity: .5; }
.bud-choice kbd { position: absolute; right: 5px; top: 4px; font-size: 7px; opacity: .28; }

.reticle { position: absolute; z-index: 9; left: 50%; top: 50%; width: 24px; height: 24px; transform: translate(-50%,-50%); pointer-events: none; transition: transform .1s; }
.reticle::before, .reticle::after, .reticle i::before, .reticle i::after { content: ""; position: absolute; width: 6px; height: 6px; border-style: solid; border-color: #fff; filter: drop-shadow(0 1px 2px #27443e); }
.reticle::before { left: 0; top: 0; border-width: 2px 0 0 2px; }.reticle::after { right: 0; top: 0; border-width: 2px 2px 0 0; }
.reticle i::before { left: 0; bottom: 0; border-width: 0 0 2px 2px; }.reticle i::after { right: 0; bottom: 0; border-width: 0 2px 2px 0; }
.reticle.locked { transform: translate(-50%,-50%) scale(1.25); }
.reticle.locked::before, .reticle.locked::after, .reticle.locked i::before, .reticle.locked i::after { border-color: var(--yellow); }

.context-pill { position: absolute; z-index: 12; left: 50%; bottom: 98px; display: flex; align-items: center; gap: 8px; transform: translateX(-50%); padding: 7px 13px 7px 7px; color: #fff; border-radius: 20px; background: rgba(36,58,54,.82); box-shadow: var(--shadow); font-size: 11px; font-weight: 800; }
kbd { font-family: inherit; }
.context-pill kbd { display: grid; place-items: center; width: 25px; height: 25px; color: var(--ink); border-radius: 50%; background: var(--yellow); box-shadow: inset 0 -2px 0 #c6a73d; }

.controls-card { position: absolute; z-index: 10; left: max(22px, env(safe-area-inset-left)); bottom: max(24px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1fr; gap: 6px 13px; padding: 10px 13px; border-radius: 16px; color: #fff; background: rgba(34,57,52,.32); backdrop-filter: blur(8px); transition: opacity 1s, transform 1s; }
.controls-card.faded { opacity: .22; transform: translateY(10px); }
.controls-card div { display: flex; align-items: center; gap: 6px; font-size: 8px; font-weight: 700; }
.controls-card kbd { min-width: 28px; padding: 3px 5px; border-radius: 5px; color: var(--ink); background: #fffbdcdd; text-align: center; font-size: 7px; font-weight: 900; }
.discoveries { position: absolute; z-index: 10; top: max(84px, calc(env(safe-area-inset-top) + 72px)); right: max(24px, env(safe-area-inset-right)); display: flex; flex-direction: column; align-items: end; gap: 5px; color: #fff; text-shadow: 0 1px 4px #27453f; font-size: 10px; font-weight: 850; }
.discoveries i { color: var(--yellow); font-style: normal; }
.reset-button { position: absolute; z-index: 10; right: max(24px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); }

.world-message { position: absolute; z-index: 13; left: 50%; top: 18%; min-width: 280px; max-width: min(460px, 80vw); transform: translateX(-50%); padding: 13px 18px; border-radius: 17px; color: var(--ink); background: #fff9e9ee; box-shadow: var(--shadow); text-align: center; animation: message-in .35s cubic-bezier(.2,.8,.2,1); }
.world-message strong { display: block; font-size: 15px; }.world-message span { display: block; margin-top: 2px; font-size: 10px; opacity: .64; }
@keyframes message-in { from { opacity: 0; transform: translate(-50%,-12px) scale(.92); } }

.loading-screen { position: absolute; z-index: 100; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ink); background: radial-gradient(circle at 50% 35%, #d8f4d4, #96d9d1 58%, #75c3c1); transition: opacity .75s ease, visibility .75s; }
.loading-screen.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-screen h1 { display: flex; gap: 4px; margin: 8px 0 0; font-size: clamp(55px, 10vw, 96px); letter-spacing: -.12em; line-height: 1; filter: drop-shadow(0 8px 0 #fff6); }
.loading-screen h1 span:nth-child(1) { color: #ed727d; transform: rotate(-7deg); }.loading-screen h1 span:nth-child(2) { color: #f4c74f; transform: translateY(5px) rotate(3deg); }.loading-screen h1 span:nth-child(3) { color: #65b977; transform: rotate(-3deg); }.loading-screen h1 span:nth-child(4) { color: #708cd1; transform: translateY(3px) rotate(6deg); }
.loading-screen p { margin: 12px 0 25px; font-size: 13px; font-weight: 800; }
.loading-screen button { min-width: 200px; padding: 13px 24px; border-radius: 24px; color: #fff; background: var(--ink); box-shadow: 0 8px 0 #172a26, var(--shadow); font-weight: 900; }
.loading-screen button:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 10px 0 #172a26, var(--shadow); }
.loading-screen button:disabled { opacity: .55; cursor: wait; }
.loading-screen small { margin-top: 20px; font-size: 9px; font-weight: 700; opacity: .5; }
.loading-bud { position: relative; width: 77px; height: 70px; border-radius: 50% 50% 44% 46%; background: var(--yellow); box-shadow: inset 0 -8px 0 #dfa93d33, 0 13px 25px #47776c33; animation: loading-hop .75s ease-in-out infinite alternate; }
.loading-bud i { position: absolute; top: 26px; width: 9px; height: 12px; border-radius: 50%; background: var(--ink); }.loading-bud i:first-child { left: 19px; }.loading-bud i:nth-child(2) { right: 19px; }
.loading-bud b { position: absolute; left: 50%; top: 44px; width: 16px; height: 7px; transform: translateX(-50%); border-bottom: 3px solid var(--ink); border-radius: 50%; }
@keyframes loading-hop { to { transform: translateY(-12px) scale(1.05,.95) rotate(3deg); } }

.touch-controls { position: absolute; z-index: 20; inset: 0; pointer-events: none; }
.joystick { position: absolute; left: max(25px, env(safe-area-inset-left)); bottom: max(28px, env(safe-area-inset-bottom)); width: 100px; height: 100px; border-radius: 50%; background: #fff4; border: 2px solid #fff5; pointer-events: auto; touch-action: none; }
.joystick i { position: absolute; left: 30px; top: 30px; width: 40px; height: 40px; border-radius: 50%; background: #fffbdcdd; box-shadow: var(--shadow); }
.touch-actions { position: absolute; right: max(20px, env(safe-area-inset-right)); bottom: max(25px, env(safe-area-inset-bottom)); display: flex; align-items: end; gap: 9px; pointer-events: auto; }
.touch-actions button { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%; color: var(--ink); background: #fffbdcdd; box-shadow: var(--shadow); }
.touch-actions button:nth-child(2) { width: 78px; height: 78px; background: var(--yellow); }
.touch-actions b { font-size: 21px; }.touch-actions span { font-size: 7px; font-weight: 1000; }

#rotate-device { position: absolute; z-index: 200; inset: 0; display: flex; align-items: center; justify-content: center; padding: 35px; color: #fff; background: var(--ink); text-align: center; font-weight: 900; }
#rotate-device span { width: 18rem; max-width: 100%; line-height: 1.35; overflow-wrap: anywhere; }

@media (pointer: coarse), (max-width: 850px) {
  .touch-controls { display: block !important; }
  .controls-card, .reset-button, .reticle { display: none; }
  .bud-wheel { bottom: auto; top: max(72px, calc(env(safe-area-inset-top) + 60px)); padding: 5px; gap: 2px; }
  .bud-choice { min-width: 48px; grid-template-columns: 29px; grid-template-rows: 29px 10px; justify-items: center; height: 47px; padding: 2px 6px; }
  .bud-choice i { grid-row: 1; }.bud-choice span { font-size: 7px; }.bud-choice b { display: none; }.bud-choice kbd { display: none; }
  .context-pill { bottom: 122px; }
  .discoveries { top: auto; bottom: 126px; right: 18px; font-size: 8px; }
  .island-name { padding: 6px 11px; }.island-name strong { font-size: 9px; }.island-name span { font-size: 6px; }
}
@media (orientation: portrait) and (max-width: 620px) {
  #rotate-device { display: flex !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
