/* ---------- old-school RPG (Final Fantasy) skin ----------
   Pure black windows, crisp white borders, square corners, pixel font. */

@font-face {
	font-family: "m5x7";
	src: url("fonts/m5x7.ttf") format("truetype");
	font-display: block;
}

:root {
	--bg: #000;
	--panel: #000;
	--ink: #fff;
	--muted: #9a9a9a;
	--accent: #f8d860; /* gold — FF numbers / highlights */
	--danger: #e8504a;
	--border: #fff;
	--line: #3a3a3a;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	min-height: 100vh;
	background: var(--bg);
	color: var(--ink);
	font:
		16px/1.4 "m5x7",
		monospace;
	letter-spacing: 0.02em;
	display: flex;
	justify-content: center;
	/* keep the pixel font sharp instead of anti-aliased */
	-webkit-font-smoothing: none;
	-moz-osx-font-smoothing: grayscale;
	font-smooth: never;
	image-rendering: pixelated;
}

#app {
	width: 100%;
	max-width: 540px;
	padding: 2rem 1.25rem 4rem;
}

h1 {
	margin: 0;
	color: var(--accent);
	font-size: 2.4rem;
	letter-spacing: 0.04em;
	text-shadow:
		2px 2px 0 #000,
		0 0 18px rgba(248, 216, 96, 0.35);
}

.tagline {
	margin-top: 0.25rem;
	color: #e8e0c8;
	font-size: 1.1rem;
	text-shadow:
		1px 1px 0 #000,
		-1px 1px 0 #000,
		1px -1px 0 #000,
		-1px -1px 0 #000,
		0 0 10px rgba(0, 0, 0, 0.9);
}

#landing-logo {
	display: block;
	width: 200px;
	max-width: 70vw;
	height: auto;
	margin: 0 auto 0.5rem;
	image-rendering: pixelated;
	filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.75));
}

h2 {
	margin: 2rem 0 0.75rem;
	font-size: 1.4rem;
	color: var(--accent);
}

.tabs {
	display: flex;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

.tab {
	flex: 1;
	background: #000;
	border: 2px solid var(--line);
	color: var(--muted);
	padding: 0.6rem;
	border-radius: 0;
	cursor: pointer;
}

.tab.active {
	color: var(--ink);
	border-color: var(--border);
}

/* The classic FF "window": black fill, white frame, square corners. */
.card {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	background: #000;
	padding: 1.25rem;
	border-radius: 0;
	border: 3px solid var(--border);
	box-shadow:
		inset 0 0 0 2px #000,
		inset 0 0 0 3px var(--border);
}

label {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	font-size: 1rem;
	color: var(--muted);
}

input,
select {
	background: #000;
	border: 2px solid var(--border);
	color: var(--ink);
	padding: 0.6rem;
	border-radius: 0;
	font-family: inherit;
	font-size: 1.1rem;
}

button {
	background: #000;
	color: var(--ink);
	border: 2px solid var(--border);
	padding: 0.6rem 0.9rem;
	border-radius: 0;
	font-family: inherit;
	font-size: 1.1rem;
	font-weight: 400;
	cursor: pointer;
}

/* Selected menu entry feel: invert + a pointer cursor. */
button:hover:not(:disabled) {
	background: var(--ink);
	color: #000;
}

button.link {
	background: none;
	border: none;
	color: var(--muted);
	padding: 0.2rem 0.3rem;
	text-decoration: none;
}

button.link:hover:not(:disabled) {
	background: none;
	color: var(--accent);
}

.wallet-card {
	align-items: center;
	text-align: center;
	gap: 1rem;
	padding: 2rem 1.5rem;
}

#connect-wallet {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	width: 100%;
	justify-content: center;
	background: #000;
	border: 2px solid var(--accent);
	color: var(--accent);
	font-size: 1.2rem;
	padding: 0.85rem;
}

#connect-wallet:hover:not(:disabled) {
	background: var(--accent);
	color: #000;
}

#connect-wallet:disabled {
	opacity: 0.6;
	cursor: default;
}

.wallet-hint {
	margin: 0;
	color: var(--muted);
	font-size: 0.95rem;
}

.account-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.75rem 0;
	border-bottom: 2px solid var(--line);
}

.character-list,
.server-list {
	list-style: none;
	margin: 0 0 1rem;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.character-list li,
.server-list li {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: #000;
	border: 2px solid var(--border);
	border-radius: 0;
	padding: 0.75rem 1rem;
}

.char-meta {
	color: var(--muted);
	font-size: 1rem;
}

.delete-btn {
	background: #000;
	border: 2px solid var(--danger);
	color: var(--danger);
	padding: 0.25rem 0.5rem;
	font-size: 0.95rem;
}

.delete-btn:hover:not(:disabled) {
	background: var(--danger);
	color: #000;
}

.dot {
	display: inline-block;
	width: 0.6rem;
	height: 0.6rem;
	border-radius: 0;
	margin-right: 0.4rem;
	background: #4caf50;
}

.dot.off {
	background: #555;
}

.empty {
	color: var(--muted);
}

.message {
	margin-top: 1rem;
	min-height: 1.5rem;
	color: var(--accent);
}

.message.error {
	color: var(--danger);
}

/* ---------- landing backdrop (simulated game world) ---------- */

/* The living-world canvas sits behind everything; the overlay darkens it so the
   centred login UI stays readable. #app rises above both. */
#landing-canvas {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100vh;
	z-index: 0;
	display: block;
	background: #1b2417;
	image-rendering: pixelated;
}

#landing-overlay {
	position: fixed;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	background:
		radial-gradient(125% 95% at 50% 40%, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.5) 52%, rgba(0, 0, 0, 0.86) 100%),
		linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.15) 28%, rgba(0, 0, 0, 0.15) 68%, rgba(0, 0, 0, 0.75) 100%);
}

#app {
	position: relative;
	z-index: 2;
}

/* While playing, the world is the real game — hide the cosmetic backdrop. */
body.playing #landing-canvas,
body.playing #landing-overlay {
	display: none;
}

/* On the login screen, centre the hero column and let the title sit large. */
body.landing #app {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	min-height: 100vh;
	text-align: center;
}

body.landing h1 {
	font-size: 3rem;
}

body.landing .tagline {
	margin-bottom: 1.75rem;
}

body.landing #auth-view {
	width: 100%;
	max-width: 380px;
}

/* Lift the login window off the busy world with a soft drop shadow, keeping the
   FF inset frame. */
body.landing .card {
	box-shadow:
		inset 0 0 0 2px #000,
		inset 0 0 0 3px var(--border),
		0 14px 50px rgba(0, 0, 0, 0.85);
}

.players-badge {
	align-self: center;
	font-size: 0.95rem;
	color: #5dd35d;
	border: 2px solid var(--line);
	border-radius: 0;
	padding: 0.15rem 0.7rem;
	letter-spacing: 0.04em;
}

.players-badge.off {
	color: var(--muted);
}

.class-strip {
	margin: 1.1rem 0 0;
	color: var(--muted);
	font-size: 0.95rem;
	text-align: center;
	letter-spacing: 0.03em;
}

/* Top-left corner menu link (guide). A small FF-style window pinned over the
   backdrop; sits above the overlay so it stays clickable on the landing. */
.corner-link {
	position: fixed;
	top: 0.8rem;
	left: 0.8rem;
	z-index: 3;
	background: #000;
	border: 2px solid var(--border);
	border-radius: 0;
	color: var(--ink);
	text-decoration: none;
	padding: 0.4rem 0.7rem;
	font-size: 1rem;
	letter-spacing: 0.03em;
	box-shadow:
		inset 0 0 0 1px #000,
		inset 0 0 0 2px var(--border);
}

.corner-link:hover {
	background: var(--accent);
	color: #000;
	border-color: var(--accent);
}

/* The guide link belongs to the landing/menu chrome; hide it in-world. */
body.playing .corner-link {
	display: none;
}

/* Landing-only link to the game's X account, pinned bottom-centre. Reuses the
   FF-style window chrome of .corner-link. */
.social-link {
	position: fixed;
	bottom: 0.8rem;
	left: 50%;
	transform: translateX(-50%);
	z-index: 3;
	background: #000;
	border: 2px solid var(--border);
	border-radius: 0;
	color: var(--ink);
	text-decoration: none;
	padding: 0.4rem 0.7rem;
	font-size: 0.95rem;
	letter-spacing: 0.03em;
	box-shadow:
		inset 0 0 0 1px #000,
		inset 0 0 0 2px var(--border);
}

.social-link:hover {
	background: var(--accent);
	color: #000;
	border-color: var(--accent);
}

/* Belongs to the landing chrome; hide it in-world. */
body.playing .social-link {
	display: none;
}

/* ---------- play / game ---------- */

.char-actions {
	display: flex;
	gap: 0.35rem;
	align-items: center;
}

.play-btn {
	background: #000;
	border: 2px solid var(--accent);
	color: var(--accent);
	padding: 0.3rem 0.8rem;
	font-size: 1rem;
}

.play-btn:hover:not(:disabled) {
	background: var(--accent);
	color: #000;
}

/* While in the game world, fill the whole viewport: the play view becomes a
   fixed overlay so the canvas can stretch edge to edge (true fullscreen feel). */
body.playing {
	overflow: hidden;
}

body.playing #app {
	max-width: none;
	width: 100%;
	padding: 0;
}

body.playing h1,
body.playing .tagline,
body.playing #landing-logo {
	display: none;
}

body.playing #play-view {
	position: fixed;
	inset: 0;
	z-index: 10;
	display: flex;
	flex-direction: column;
	background: var(--bg);
}

/* In-world, the status readout is a compact FF-style window pinned to the
   top-left corner over the canvas (stacked: name, bars, gold, actions). */
body.playing .game-hud {
	position: absolute;
	top: 0.6rem;
	left: 0.6rem;
	z-index: 6;
	width: 14rem;
	flex-direction: column;
	align-items: stretch;
	gap: 0.5rem;
	border-radius: 0;
	border: 3px solid var(--border);
	box-shadow:
		inset 0 0 0 2px #000,
		inset 0 0 0 3px var(--border);
}

body.playing .hud-bars {
	width: 100%;
}

body.playing .hud-end {
	align-items: stretch;
}

body.playing .hud-actions {
	justify-content: space-between;
}

body.playing .game-wrap {
	flex: 1;
	min-height: 0;
}

body.playing #game-canvas {
	width: 100%;
	height: 100%;
	border: none;
	border-radius: 0;
}

body.playing .controls-hint {
	margin: 0;
	padding: 0.4rem 0;
}

/* World map (M) is drawn on the canvas; hide the on-canvas HUD/chrome and any
   open panels while it's up so nothing floats over the map. */
body.wm-open .game-hud,
body.wm-open .target-panel,
body.wm-open .chat-box,
body.wm-open .controls-hint,
body.wm-open .game-panel {
	display: none !important;
}

.game-hud {
	display: flex;
	align-items: center;
	gap: 1rem;
	background: #000;
	border: 2px solid var(--border);
	border-radius: 0;
	padding: 0.6rem 0.9rem;
}

.hud-id {
	display: flex;
	flex-direction: column;
	min-width: 7rem;
}

.hud-bars {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.hud-end {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 0.25rem;
}

.hud-actions {
	display: flex;
	gap: 0.75rem;
	align-items: center;
}

.bar {
	position: relative;
	height: 16px;
	background: #000;
	border: 2px solid var(--border);
	border-radius: 0;
	overflow: hidden;
}

.bar-fill {
	height: 100%;
	width: 0;
	transition: width 0.12s linear;
}

.bar.hp .bar-fill {
	background: #4caf50;
}

.bar.mp {
	height: 14px;
}

.bar.mp .bar-fill {
	background: #4f7fd6;
}

.bar.xp {
	height: 12px;
}

.bar.xp .bar-fill {
	background: var(--accent);
}

.hud-skill {
	font-size: 0.95rem;
	color: var(--muted);
	background: #000;
	border: 2px solid var(--line);
	border-radius: 0;
	padding: 0.1rem 0.4rem;
}

.hud-skill.ready {
	color: var(--accent);
	border-color: var(--accent);
}

.hud-skill[hidden] {
	display: none;
}

.bar.mob .bar-fill {
	background: var(--danger);
}

.bar-text {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.85rem;
	color: var(--ink);
	text-shadow: 1px 1px 0 #000;
}

.game-wrap {
	position: relative;
	line-height: 0;
}

#game-canvas {
	width: 100%;
	display: block;
	background: #1b2417;
	border: 2px solid var(--border);
	border-top: none;
	border-radius: 0;
	cursor: crosshair;
	touch-action: none;
}

.target-panel {
	position: absolute;
	top: 0.6rem;
	left: 50%;
	transform: translateX(-50%);
	width: 12rem;
	background: #000;
	border: 2px solid var(--border);
	border-radius: 0;
	padding: 0.35rem 0.5rem;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	line-height: 1.3;
}

/* `hidden` attribute must win over the flex display above. */
.target-panel[hidden] {
	display: none;
}

.target-panel span {
	font-size: 0.95rem;
	text-align: center;
}

.controls-hint {
	margin: 0.6rem 0 0;
	color: var(--muted);
	font-size: 0.95rem;
	text-align: center;
}

/* ---------- in-game overlay panels (inventory / shop / transporter) ---------- */
.game-panel {
	position: absolute;
	top: 0.6rem;
	right: 0.6rem;
	width: 18rem;
	max-height: calc(100% - 1.2rem);
	overflow-y: auto;
	background: #000;
	border: 3px solid var(--border);
	border-radius: 0;
	box-shadow:
		inset 0 0 0 2px #000,
		inset 0 0 0 3px var(--border);
	line-height: 1.3;
	z-index: 5;
}

.game-panel[hidden] {
	display: none;
}

.panel-body {
	padding: 0.6rem 0.7rem 0.8rem;
}

.panel-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 0.4rem;
	border-bottom: 2px solid var(--line);
	padding-bottom: 0.3rem;
}

.panel-head strong {
	font-size: 1.05rem;
	color: var(--accent);
}

.panel-x {
	background: none;
	border: none;
	color: var(--muted);
	cursor: pointer;
	font-size: 1.1rem;
	padding: 0 0.2rem;
}

.panel-x:hover {
	background: none;
	color: var(--ink);
}

.panel-sub {
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--muted);
	margin: 0.5rem 0 0.3rem;
}

.item-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 0.3rem;
}

.item-cell {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.15rem;
	background: #000;
	border: 2px solid var(--border);
	border-radius: 0;
	padding: 0.4rem 0.3rem;
	color: var(--ink);
	cursor: pointer;
	text-align: center;
	min-height: 3.4rem;
}

.item-cell:hover:not(:disabled) {
	background: var(--ink);
	color: #000;
}

.item-cell:hover:not(:disabled) .item-sub {
	color: #000;
}

.item-cell:disabled {
	cursor: default;
	opacity: 0.85;
}

.item-cell.equipped {
	border-color: var(--accent);
}

.item-cell.cant {
	opacity: 0.45;
}

/* Cropped sprite from an item sheet (pack_20vt8 / pack_1a / community). The
   sprite, sheet size and offset are set inline from gamedata's `icon` array. */
.item-icon {
	flex: none;
	image-rendering: pixelated;
	background-repeat: no-repeat;
}

.item-name {
	font-size: 0.95rem;
	line-height: 1.1;
}

.item-sub {
	font-size: 0.85rem;
	color: var(--muted);
}

.muted {
	font-size: 0.95rem;
	color: var(--muted);
}

.travel-list {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.travel-dest {
	background: #000;
	border: 2px solid var(--border);
	border-radius: 0;
	padding: 0.4rem 0.5rem;
	color: var(--ink);
	cursor: pointer;
	text-align: left;
	font-size: 1rem;
}

.travel-dest:hover:not(:disabled) {
	background: var(--ink);
	color: #000;
}

.travel-dest:disabled {
	cursor: default;
	color: var(--muted);
}

/* ---------- in-game world chat ---------- */
/* Pinned bottom-left over the canvas. The box itself ignores pointer events so it
   never blocks click-to-move/attack; only the input is interactive. */
.chat-box {
	position: absolute;
	left: 0.6rem;
	bottom: 0.6rem;
	z-index: 6;
	width: 22rem;
	max-width: 42vw;
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	pointer-events: none;
}

.chat-log {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.2rem;
	max-height: 13rem;
	overflow-y: auto;
	font-size: 1.05rem;
	line-height: 1.35;
	text-shadow: 1px 1px 0 #000;
}

/* Each line gets its own dark backdrop hugging the text so it stays readable
   over a busy game canvas; flex-start above shrinks the pill to content width. */
.chat-line {
	max-width: 100%;
	word-break: break-word;
	background: rgba(0, 0, 0, 0.6);
	padding: 0.12rem 0.4rem;
	border-radius: 3px;
}

.chat-line .who {
	color: var(--accent);
}

/* System messages (rare-loot announcements) — green. */
.chat-line.system {
	color: #4caf50;
}

.chat-input {
	pointer-events: auto;
	background: #000;
	border: 2px solid var(--line);
	color: var(--ink);
	border-radius: 0;
	padding: 0.3rem 0.45rem;
	font-family: inherit;
	font-size: 1rem;
	opacity: 0.65;
	transition: opacity 0.1s;
}

.chat-box:hover .chat-input {
	opacity: 0.9;
}

.chat-input.active {
	opacity: 1;
	border-color: var(--border);
}

/* ---------- game guide page (guide.html) ---------- */
/* Standalone docs page: the same living-world backdrop, with a scrollable
   column of FF-style windows over it. */
.guide {
	position: relative;
	z-index: 2;
	width: 100%;
	max-width: 720px;
	margin: 0 auto;
	padding: 4.5rem 1.25rem 4rem;
}

.guide h1 {
	margin-bottom: 0.25rem;
}

.guide .lead {
	color: var(--muted);
	font-size: 1.1rem;
	margin: 0 0 1.5rem;
}

.guide .card {
	margin-bottom: 1.25rem;
	gap: 0.6rem;
	box-shadow:
		inset 0 0 0 2px #000,
		inset 0 0 0 3px var(--border),
		0 14px 50px rgba(0, 0, 0, 0.85);
}

.guide .card > h2 {
	margin: 0 0 0.25rem;
}

.guide p {
	margin: 0;
	line-height: 1.5;
}

.guide ul {
	margin: 0;
	padding-left: 1.2rem;
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.guide a {
	color: var(--accent);
}

/* Inline key cap, e.g. WASD / E / Enter. */
.kbd {
	display: inline-block;
	min-width: 1.3rem;
	text-align: center;
	background: #000;
	border: 2px solid var(--border);
	border-radius: 0;
	color: var(--ink);
	padding: 0 0.35rem;
	font-size: 0.95rem;
	box-shadow: 1px 1px 0 #000;
}

/* Class / reference rows. */
.guide-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 1rem;
}

.guide-table th,
.guide-table td {
	text-align: left;
	padding: 0.4rem 0.5rem;
	border-bottom: 2px solid var(--line);
	vertical-align: top;
}

.guide-table th {
	color: var(--accent);
	font-weight: 400;
}

.guide-table td:first-child {
	color: var(--ink);
	white-space: nowrap;
}

.guide-table .role {
	color: var(--muted);
}

/* Back-to-game corner link reuses .corner-link; keep it visible on the guide. */
body.guide-page {
	display: block;
}

/* ---------- guide: embedded real item icons + callouts ---------- */
/* guide.html crops these from the item sheet (inline script, keyed off
   data-item), so the docs show the actual in-game art. */
.gicon {
	display: inline-block;
	vertical-align: middle;
	image-rendering: pixelated;
	background-repeat: no-repeat;
	width: 40px;
	height: 40px;
}
.guide .icon-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem;
	margin: 0.1rem 0;
}
.guide .icon-row .lbl {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
}
.guide .warn {
	border-left: 3px solid #d9694a;
	background: rgba(217, 105, 74, 0.12);
	padding: 0.45rem 0.7rem;
	line-height: 1.45;
}
.guide .npc {
	color: var(--accent);
	font-weight: bold;
}
