* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { background: #efefec; color: #30332f; font-family: Arial, Helvetica, sans-serif; }
canvas { display: block; width: 100%; height: 100%; }
#overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgb(247 247 243 / 34%); backdrop-filter: blur(5px); }
.intro { text-align: center; padding: 28px; }
button { border: 1px solid #383d35; border-radius: 4px; background: #383d35; color: white; padding: 16px 22px; font: inherit; font-size: 13px; cursor: pointer; }
button:hover { background: #4e5549; }
button:focus-visible { outline: 2px solid #383d35; outline-offset: 5px; }
button span { margin-left: 32px; }
button.secondary { background: transparent; color: #383d35; }
button.secondary:hover { background: #e4e6df; }
#menu, #lobby { display: grid; gap: 12px; justify-items: center; }
/* These ID rules outrank the browser's [hidden] rule, so restate it. */
#menu[hidden], #lobby[hidden] { display: none; }
.mode-row { display: flex; gap: 8px; margin-bottom: 6px; }
.mode { display: grid; gap: 4px; width: 190px; padding: 12px 14px; text-align: left; background: transparent; color: #55584f; border: 1px solid #bfc1b9; }
.mode strong { font-weight: 500; color: #30332f; }
.mode small { margin: 0; font-size: 10px; line-height: 1.5; color: #8a8e83; }
.mode:hover { background: #e4e6df; }
.mode.selected { border: 2px solid #58654a; background: #edf2e5; padding: 11px 13px; }
body.outdoors #overlay { background: rgb(206 226 244 / 40%); }
@media (max-width: 540px) { .mode-row { flex-direction: column; } }
.menu-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; justify-content: center; }
.field { display: grid; gap: 5px; text-align: left; font-size: 11px; color: #7c7e77; letter-spacing: .04em; }
.field input { border: 1px solid #bfc1b9; border-radius: 4px; background: #fbfbf8; color: #30332f; padding: 11px 12px; font: inherit; font-size: 13px; width: 200px; }
.code-field input { width: 110px; text-transform: uppercase; letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.field input:focus-visible { outline: 2px solid #383d35; outline-offset: 2px; }
.room-line { margin: 0; font-size: 13px; color: #55584f; }
.room-line strong { font-size: 24px; letter-spacing: .22em; margin-left: 8px; color: #30332f; }
.room-link { margin: 0; font-size: 11px; color: #7c7e77; word-break: break-all; user-select: all; }
#players { list-style: none; margin: 0; padding: 0; font-size: 12px; color: #55584f; line-height: 1.9; }
#players .offline { color: #a4a69f; }
#players .you { color: #30332f; font-weight: bold; }
#status:not([hidden]) { margin: 0; font-size: 12px; color: #8a5a4a; }
#roster { position: fixed; top: 16px; left: 16px; font-size: 11px; color: #65695e; background: #ffffffc8; border-radius: 4px; padding: 7px 10px; pointer-events: none; display: none; max-width: 260px; }
#roster-code { display: block; letter-spacing: .2em; color: #30332f; margin-bottom: 3px; }
#roster-players .offline { color: #a4a69f; }
body.playing #roster:not([hidden]) { display: block; }
.controls { margin-top: 30px; font-size: 11px; color: #7c7e77; line-height: 2.5; }
kbd { display: inline-block; border: 1px solid #bfc1b9; border-radius: 3px; font: inherit; line-height: 20px; width: 20px; margin-right: 3px; }
.controls span, #hint span { margin: 0 9px; }
#crosshair { display: none; position: fixed; left: 50%; top: 50%; width: 3px; height: 3px; border-radius: 50%; background: #70746a; opacity: .45; pointer-events: none; }
#crosshair.diggable { background: transparent; opacity: .85; }
.dig-marker, .dig-prompt { display: none; position: absolute; left: 50%; transform: translateX(-50%); color: #65695e; }
.dig-marker { top: 50%; transform: translate(-50%, -50%); font-size: 20px; line-height: 1; }
.dig-prompt { top: 17px; font-size: 11px; letter-spacing: .04em; }
#crosshair.diggable .dig-marker, #crosshair.diggable .dig-prompt { display: block; }
#hint { display: none; position: fixed; bottom: 24px; width: 100%; text-align: center; color: #72756c; font-size: 11px; pointer-events: none; }
#hotbar { display: none; position: fixed; bottom: 57px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; }
.hotbar-slot { position: relative; width: 70px; height: 64px; border: 1px solid #80857a; border-radius: 7px; background: rgb(248 249 245 / 78%); box-shadow: 0 2px 12px #42483b15, inset 0 0 0 3px #ffffff88; }
.hotbar-items { display: flex; gap: 8px; }
.hotbar-slot.selected { border: 2px solid #58654a; box-shadow: 0 0 0 2px #ffffff80; }
.brush-icon { position: absolute; left: 31px; top: 15px; width: 7px; height: 29px; background: #8b7255; border-radius: 3px; transform: rotate(30deg); }
.brush-icon::before { content: ''; position: absolute; top: -5px; left: -5px; width: 17px; height: 13px; background: var(--paint-color,#82a67a); border-bottom: 4px solid #afb5aa; border-radius: 4px 4px 0 0; }
#paint-count { position: absolute; bottom: 6px; right: 8px; color: #444d3b; font-size: 13px; font-variant-numeric: tabular-nums; }
#action-hint { display: none; position: fixed; top: calc(50% + 42px); left: 50%; transform: translateX(-50%); text-align: center; font-size: 11px; color: #4c5745; background: #ffffffe0; border-radius: 4px; padding: 7px 12px; pointer-events: none; max-width: 360px; }
body.playing #action-hint:not(:empty) { display: block; }
#paint-menu { position: fixed; inset: 0; z-index: 5; overflow: auto; background: #eceee7b8; backdrop-filter: blur(9px); padding: 30px 18px; }
#paint-menu[hidden] { display: none; }
.paint-panel { width: min(650px,100%); margin: auto; padding: 30px; border: 1px solid #c8cdc0; border-radius: 15px; background: #f9faf6; box-shadow: 0 20px 80px #30372b12; }
.menu-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.menu-kicker { font-size: 9px; letter-spacing: .18em; color: #7d8772; margin: 0 0 10px; }
h1 { font-size: 31px; font-weight: 400; letter-spacing: -.04em; margin: 0; }
h2 { font-size: 13px; font-weight: 500; margin-top: 27px; }
.menu-description, .recipe-help { color: #747d6c; font-size: 12px; line-height: 1.6; }
.palette { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); gap: 6px; margin-top: 20px; }
.swatch { background: transparent; color: #626c57; border: 1px solid #d7dbcf; padding: 9px 2px; font-size: 10px; }
.swatch::before { content: ''; display: block; width: 28px; height: 28px; background: var(--swatch); border: 1px solid #00000015; border-radius: 50%; margin: 0 auto 7px; }
@media (max-width: 540px) { .palette { grid-template-columns: repeat(4,minmax(0,1fr)); } .paint-panel { padding: 20px; } }
.swatch:hover, .recipe:hover { background: #eef1e7; }
[data-paint].selected { border-color: #687e52; background: #edf2e5; }
.recipe-list { display: grid; gap: 9px; }
.recipe { display: flex; align-items: center; gap: 20px; text-align: left; padding: 15px; background: transparent; color: #46533c; border: 1px solid #d7dbcf; }
.recipe span { margin: 0; }
.recipe strong { display: block; font-size: 13px; font-weight: 500; }
small { display: block; font-size: 11px; line-height: 1.6; color: #7b8374; margin-top: 4px; }
.recipe-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.recipe-grid { display: grid; grid-template-columns: repeat(var(--cols, 2), 11px); gap: 2px; flex-shrink: 0; padding: 4px; width: 46px; justify-content: center; }
.recipe-grid i { width: 11px; height: 11px; border: 1px solid #00000015; background: var(--recipe, #99703e); }
.recipe-where { display: inline-block; margin-left: 6px; padding: 1px 5px; border-radius: 3px; background: #eef1e7; color: #6b7660; font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
button:disabled { opacity: .4; cursor: default; }
#paint-menu-status { font-size: 12px; color: #717b66; margin-bottom: 0; min-height: 16px; }
body.menu-open #overlay { display: none; }
.slot-key { position: absolute; top: 6px; left: 8px; color: #8a8e83; font-size: 10px; }
.cube-icon { position: absolute; width: 23px; height: 23px; left: 23px; top: 15px; background: #fff; border: 1px solid #b7bdb0; transform: rotate(-12deg) skewY(8deg); box-shadow: 4px 4px 0 #b5bbae, 5px 5px 0 #969e8e; }
#debris-count { position: absolute; bottom: 6px; right: 8px; color: #444d3b; font-size: 13px; font-variant-numeric: tabular-nums; }
.hotbar-label { display: block; margin-top: 7px; color: #72796a; font-size: 10px; letter-spacing: .08em; }
.mode-control { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 12px; white-space: nowrap; font-size: 11px; color: #656d5b; }
.mode-control kbd { background: #ffffff80; }
#hotbar.empty .cube-icon { opacity: .4; }
body.playing #hotbar { display: block; }
@media (max-width: 700px) { #hint { padding: 0 14px; font-size: 10px; line-height: 1.7; bottom: 12px; } #hotbar { bottom: 70px; } }
body.playing #overlay { display: none; }
body.playing #crosshair, body.playing #hint { display: block; }
