/* Crazy Digging Holes. Colors come from /assets/theme.css tokens where they
   exist, with local fallbacks so the game still reads if a token is missing.

   Every rule that sets `display` has a companion [hidden] rule — without it
   the hidden attribute silently does nothing.
   Rectangular radii never exceed 8px; pills are 999px, a separate pattern. */

:root {
	--cdh-ink:    var(--text, #10151a);
	--cdh-panel:  var(--surface, #ffffff);
	--cdh-line:   var(--border, #d7dee5);
	--cdh-accent: var(--accent, #2f6fd0);
	--cdh-gem:    #7d4fd0;
	--cdh-good:   #1f8a4c;
	--cdh-bad:    #b3261e;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	height: 100%;
	overflow: hidden;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	color: var(--cdh-ink);
	background: #9fb8c4;
	-webkit-user-select: none;
	user-select: none;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- chips ---------- */

.cdh-chip-row { position: fixed; top: 10px; left: 10px; display: flex; gap: 8px; z-index: 5; }
.cdh-chip-row[hidden] { display: none; }

.cdh-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 14px;
	border-radius: 999px;
	background: var(--cdh-panel);
	border: 1px solid var(--cdh-line);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.cdh-chip[hidden] { display: none; }
.cdh-chip.is-gem   { color: var(--cdh-gem); }
.cdh-chip.is-quiet { font-weight: 500; opacity: .75; }

.cdh-xp { position: fixed; top: 48px; left: 10px; display: flex; align-items: center; gap: 8px; z-index: 5; }
.cdh-xp[hidden] { display: none; }
.cdh-xp-label { font-size: 12px; font-weight: 700; }
.cdh-xp-track {
	display: block; width: 140px; height: 7px;
	border-radius: 999px; background: rgba(0,0,0,.22); overflow: hidden;
}
.cdh-xp-fill { display: block; height: 100%; width: 0; background: var(--cdh-accent); border-radius: 999px; }

.cdh-hole-chips {
	position: fixed; top: 10px; right: 10px; z-index: 5;
	display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
	max-height: 46vh; overflow-y: auto;
}
.cdh-hole-chips[hidden] { display: none; }

.cdh-hole-chip {
	display: grid; gap: 1px;
	padding: 6px 12px; min-width: 160px;
	border-radius: 8px;
	border: 1px solid var(--cdh-line);
	background: var(--cdh-panel);
	font: inherit; color: var(--cdh-ink); text-align: right; cursor: pointer;
}
.cdh-hole-chip[hidden] { display: none; }
.cdh-hole-chip.is-on { border-color: var(--cdh-accent); box-shadow: 0 0 0 2px rgba(47,111,208,.22); }

.cdh-sub { font-size: 11px; opacity: .7; font-weight: 500; }

.cdh-treasure { position: fixed; bottom: 68px; left: 10px; z-index: 5; }

.cdh-hint {
	position: fixed; bottom: 104px; left: 10px; z-index: 5;
	max-width: min(420px, 84vw);
	font-weight: 500; font-size: 12px;
	border-color: #c9922a;
}
.cdh-hint[hidden] { display: none; }

.cdh-claim {
	position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%);
	display: flex; align-items: center; gap: 10px;
	max-width: min(560px, 94vw);
	padding: 8px 12px; border-radius: 8px;
	background: var(--cdh-panel); border: 1px solid var(--cdh-line);
	font-size: 13px; z-index: 6;
	box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.cdh-claim[hidden] { display: none; }
.cdh-claim.is-loud { border-color: var(--cdh-gem); box-shadow: 0 0 0 2px rgba(125,79,208,.25); }

.cdh-x { border: 0; background: none; font-size: 18px; line-height: 1; cursor: pointer; color: inherit; }

/* ---------- buttons ---------- */

.cdh-btn {
	display: inline-block;
	padding: 9px 14px;
	border-radius: 8px;
	border: 1px solid var(--cdh-line);
	background: var(--cdh-accent);
	color: #fff; font: inherit; font-weight: 600;
	cursor: pointer; text-decoration: none; text-align: center;
}
.cdh-btn[hidden] { display: none; }
.cdh-btn:disabled { opacity: .45; cursor: not-allowed; }
.cdh-btn-sm { padding: 5px 10px; font-size: 12px; }
.cdh-btn-danger { background: var(--cdh-bad); }
.cdh-btn.is-gem { background: var(--cdh-gem); }

.cdh-drawer-toggle { position: fixed; bottom: 10px; right: 10px; z-index: 7; }
.cdh-recenter { position: fixed; bottom: 10px; right: 96px; z-index: 7; }

.cdh-view {
	position: fixed; right: 10px; bottom: 54px; z-index: 7;
	display: grid;
	grid-template-columns: repeat(3, 30px);
	grid-template-areas: ".  up   ." "l  home r" ".  down lbl";
	gap: 3px; justify-items: center; align-items: center;
}
.cdh-view[hidden] { display: none; }
#tiltUp   { grid-area: up; }
#rotL     { grid-area: l; }
#viewReset{ grid-area: home; }
#rotR     { grid-area: r; }
#tiltDown { grid-area: down; }

.cdh-vbtn {
	width: 30px; height: 30px; padding: 0;
	border-radius: 8px;
	border: 1px solid var(--cdh-line);
	background: var(--cdh-panel); color: var(--cdh-ink);
	font: inherit; font-size: 12px; line-height: 1; cursor: pointer;
	box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.cdh-vbtn[hidden] { display: none; }
.cdh-vlabel { grid-area: lbl; font-size: 10px; opacity: .75; font-variant-numeric: tabular-nums; }
.cdh-recenter[hidden] { display: none; }

/* ---------- drawer ---------- */

.cdh-drawer {
	position: fixed; top: 0; right: 0; bottom: 0;
	width: min(370px, 92vw);
	display: flex; flex-direction: column;
	background: var(--cdh-panel);
	border-left: 1px solid var(--cdh-line);
	transform: translateX(100%);
	transition: transform .18s ease;
	z-index: 6;
	overflow: hidden;
}
.cdh-drawer[hidden] { display: none; }
.cdh-drawer.is-open { transform: translateX(0); }

.cdh-tabs { display: flex; border-bottom: 1px solid var(--cdh-line); }
.cdh-tabs[hidden] { display: none; }

.cdh-tab {
	flex: 1; padding: 12px 6px;
	border: 0; border-bottom: 2px solid transparent;
	background: none; font: inherit; font-weight: 600; cursor: pointer; color: inherit;
}
.cdh-tab.is-on { border-bottom-color: var(--cdh-accent); color: var(--cdh-accent); }

.cdh-panel { display: grid; gap: 10px; padding: 14px; overflow-y: auto; }
.cdh-panel[hidden] { display: none; }

.cdh-h3 { margin: 12px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; opacity: .65; }
.cdh-h4 { margin: 8px 0 0; font-size: 13px; }

.cdh-row {
	display: grid;
	grid-template-columns: 1fr auto;
	align-items: center; gap: 4px 10px;
	padding: 8px 0;
	border-bottom: 1px solid var(--cdh-line);
}
.cdh-row[hidden] { display: none; }
.cdh-row-name { font-weight: 600; }
.cdh-row .cdh-sub { grid-column: 1; }

.cdh-perk-text { display: grid; gap: 2px; }
.cdh-perk-text[hidden] { display: none; }
.cdh-perk.is-owned { opacity: .6; }
.cdh-owned { font-size: 12px; font-weight: 600; color: var(--cdh-good); }

.cdh-select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--cdh-line); font: inherit; }
.cdh-empty { margin: 4px 0; font-size: 12px; opacity: .7; }

/* ---------- toasts ---------- */

.cdh-toasts {
	position: fixed; bottom: 58px; left: 50%; transform: translateX(-50%);
	display: flex; flex-direction: column; gap: 6px; align-items: center;
	z-index: 8; pointer-events: none;
}
.cdh-toasts[hidden] { display: none; }

.cdh-toast {
	padding: 8px 14px; border-radius: 999px;
	background: rgba(16,21,26,.9); color: #fff; font-size: 13px;
	opacity: 1; transition: opacity .5s ease;
}
.cdh-toast.good { background: rgba(31,138,76,.94); }
.cdh-toast.bad  { background: rgba(179,38,30,.94); }
.cdh-toast.is-out { opacity: 0; }

/* ---------- debug ---------- */

.cdh-debug {
	position: fixed; bottom: 10px; left: 10px;
	display: grid; gap: 6px;
	max-width: 46vw; max-height: 42vh; overflow: auto;
	padding: 8px; border-radius: 8px;
	background: rgba(16,21,26,.86); color: #d8f0c8;
	font: 11px/1.35 ui-monospace, Menlo, Consolas, monospace;
	z-index: 9;
}
.cdh-debug[hidden] { display: none; }
.cdh-debug-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cdh-debug-actions[hidden] { display: none; }
.cdh-debug pre { margin: 0; white-space: pre-wrap; }

@media (max-width: 640px) {
	.cdh-hole-chips { max-height: 32vh; }
	.cdh-debug { max-width: 92vw; }
}
