* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
	width: 100%;
	height: 100%;
	background: #0c0a09;
	color: #d8c8a8;
	font-family: "Courier New", ui-monospace, monospace;
	font-weight: bold;
	overflow: hidden;
	user-select: none;
}

body { display: flex; align-items: center; justify-content: center; }

#game {
	width: min(1120px, 100vw - 16px, (100vh - 16px) * 1.72);
	display: flex;
	gap: 8px;
	padding: 8px;
	background: #2a231d;
	border: 3px solid;
	border-color: #6b5a48 #15110d #15110d #6b5a48;
}

.panel {
	background: #1a1613;
	border: 3px solid;
	border-color: #15110d #6b5a48 #6b5a48 #15110d;
}

#left { flex: 1.75; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#right { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* ---- 3D view ---- */
#view { position: relative; aspect-ratio: 16 / 10; overflow: hidden; cursor: pointer; background: #000; }
#view canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
#flash { position: absolute; inset: 0; background: #c00; opacity: 0; pointer-events: none; transition: opacity 0.35s; }
#flash.on { opacity: 0.4; transition: none; }
#floaters { position: absolute; inset: 0; pointer-events: none; }
.floater {
	position: absolute; top: 42%; transform: translateX(-50%);
	font-size: 26px; color: #ffe070; text-shadow: 2px 2px 0 #000;
	animation: floatUp 0.9s ease-out forwards;
}
.floater.miss { color: #aaa; font-size: 18px; }
@keyframes floatUp { to { top: 22%; opacity: 0; } }

#overlay {
	position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
	background: rgba(0, 0, 0, 0.78); cursor: default; transition: opacity 0.4s;
}
#overlay.hidden { opacity: 0; pointer-events: none; }
#overlay .box { text-align: center; padding: 12px; max-width: 92%; }
#overlay h1 { font-size: 56px; letter-spacing: 14px; color: #e0b050; text-shadow: 3px 3px 0 #502008; }
#overlay h2 { font-size: 16px; color: #a08868; margin-bottom: 14px; letter-spacing: 3px; }
#overlay p { font-size: 14px; margin-bottom: 12px; }
#overlay table { margin: 0 auto 16px; font-size: 13px; text-align: left; border-spacing: 12px 3px; }
#overlay td:first-child { color: #e0b050; text-align: right; white-space: nowrap; }

button {
	font: inherit; color: #d8c8a8; background: #4a3d31; cursor: pointer;
	border: 3px solid; border-color: #7d6a55 #1c1712 #1c1712 #7d6a55;
}
button:hover { background: #5a4b3c; }
button:active { border-color: #1c1712 #7d6a55 #7d6a55 #1c1712; }
#begin { font-size: 16px; padding: 8px 18px; color: #ffe0a0; }

/* ---- pad + log ---- */
#bottom { display: flex; gap: 8px; height: 132px; }
#pad { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr 1fr; gap: 4px; padding: 6px; width: 190px; flex: none; }
#pad button { font-size: 24px; line-height: 1; }
#log { flex: 1; padding: 6px 10px; font-size: 13px; line-height: 1.5; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
#log div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #8c7c64; }
#log div:last-child { color: #f0e0b8; }
#log .good { color: #8fce7a !important; }
#log .bad { color: #e0705c !important; }
#log .gold { color: #e8c050 !important; }

/* ---- party ---- */
#right { position: relative; }
#party { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card { padding: 6px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.card.selected { border-color: #e0b050; }
.card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.card .name { font-size: 14px; color: #f0e0b8; overflow: hidden; text-overflow: ellipsis; }
.card .row { font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: #15110d; background: #a08868; padding: 1px 4px; }
.card .body { display: flex; gap: 6px; align-items: stretch; }
.card .portrait { width: 64px; height: 64px; image-rendering: pixelated; border: 2px solid; border-color: #15110d #6b5a48 #6b5a48 #15110d; flex: none; cursor: pointer; }
.card .portrait:hover { border-color: #e0b050; }
.card .side { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; }
.card .cls { font-size: 11px; color: #a08868; white-space: nowrap; }
.card .hpbar { height: 9px; background: #301010; border: 1px solid #000; }
.card .hpfill { height: 100%; background: #3fa83a; width: 100%; transition: width 0.2s; }
.card .hpfill.low { background: #c8372c; }
.card .hptext { font-size: 11px; color: #d8c8a8; white-space: nowrap; }
.card .mini { font-size: 11px; color: #a08868; white-space: nowrap; }
.card .mini b { color: #e0b050; }
.card .atk { position: relative; padding: 6px 2px; font-size: 12px; overflow: hidden; white-space: nowrap; }
.card .atk .cool { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: rgba(0, 0, 0, 0.62); }
.card .atk .lbl { position: relative; }
.card .atk b { color: #e0b050; }
.card.hit { animation: cardHit 0.3s; }
.card.dead .portrait, .card.dead .side { filter: grayscale(1) brightness(0.45); }
.card.dead .hptext { color: #c8372c; }
@keyframes cardHit { 0%, 60% { background: #7a1510; transform: translateX(2px); } 30% { transform: translateX(-2px); } }

/* ---- character sheet ---- */
#sheet { position: absolute; inset: 0; z-index: 5; padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; background: #1a1613; }
#sheet.hidden { display: none; }
#sheet .sheet-head { display: flex; gap: 10px; align-items: center; }
#sheet canvas { width: 128px; height: 128px; image-rendering: pixelated; border: 3px solid; border-color: #6b5a48 #15110d #15110d #6b5a48; flex: none; }
#sheet h3 { font-size: 20px; color: #e0b050; letter-spacing: 2px; }
#sheet .sub { font-size: 12px; color: #a08868; margin-top: 3px; }
#sheet .bio { font-size: 12px; line-height: 1.45; color: #b8a888; font-weight: normal; font-style: italic; }
#sheet .attrs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
#sheet .attrs div { background: #0f0d0b; border: 1px solid #3a3028; text-align: center; padding: 3px 0; }
#sheet .attrs span { display: block; font-size: 9px; color: #8c7c64; letter-spacing: 1px; }
#sheet .attrs b { font-size: 15px; color: #f0e0b8; }
#sheet .attrs .high b { color: #8fce7a; }
#sheet .attrs .low b { color: #e0705c; }
#sheet table { width: 100%; font-size: 12px; border-collapse: collapse; }
#sheet td { padding: 2px 0; border-bottom: 1px dotted #3a3028; }
#sheet td:first-child { color: #8c7c64; }
#sheet td:last-child { text-align: right; color: #f0e0b8; }
#sheet .sheet-nav { margin-top: auto; display: grid; grid-template-columns: auto 1fr auto; gap: 6px; }
#sheet button { padding: 6px 12px; font-size: 12px; }

/* ---- compass / map / inventory ---- */
#info { flex: 1; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 8px; padding: 8px; align-items: center; justify-items: center; }
#compass { position: relative; width: 84px; height: 84px; border-radius: 50%; border: 3px solid #6b5a48; background: #0f0d0b; overflow: hidden; }
#rose { position: absolute; inset: 0; }
#rose span { position: absolute; font-size: 15px; color: #a08868; width: 20px; height: 20px; line-height: 20px; text-align: center; }
#rose .n { top: 2px; left: 29px; color: #e05040; }
#rose .s { bottom: 2px; left: 29px; }
#rose .e { right: 2px; top: 29px; }
#rose .w { left: 2px; top: 29px; }
#needle { position: absolute; left: 50%; top: 24px; width: 0; height: 0; margin-left: -6px; border: 6px solid transparent; border-bottom: 16px solid #e0b050; border-top: 0; }
#minimap { grid-row: 1 / 3; grid-column: 2; width: 100%; max-width: 220px; image-rendering: pixelated; border: 2px solid #15110d; background: #000; }
#inv { display: flex; gap: 6px; }
.slot { width: 42px; height: 42px; position: relative; background: #0f0d0b; border: 2px solid; border-color: #15110d #6b5a48 #6b5a48 #15110d; padding: 0; }
.slot canvas { position: absolute; inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px); image-rendering: pixelated; object-fit: contain; }
.slot .count { position: absolute; right: 2px; bottom: 0; font-size: 12px; color: #fff; text-shadow: 1px 1px 0 #000; z-index: 1; }
.slot.empty canvas { opacity: 0.25; }

/* site-nav:start (stripped from the downloadable copy) */
.site-back {
	position: fixed;
	top: 10px;
	left: 12px;
	z-index: 20;
	font-size: 12px;
	letter-spacing: 1px;
	text-transform: uppercase;
	text-decoration: none;
	color: #a08868;
	background: #2a231d;
	padding: 6px 12px;
	border: 2px solid;
	border-color: #6b5a48 #15110d #15110d #6b5a48;
}
.site-back:hover { color: #f0e0b8; background: #3a3128; }
.site-back:active { border-color: #15110d #6b5a48 #6b5a48 #15110d; }
.site-back:focus-visible { outline: 2px solid #e0b050; outline-offset: 2px; }
@media (max-width: 900px) { .site-back { position: static; display: inline-block; margin: 8px 0 0 8px; } }
/* site-nav:end */
