/* ==========================================================================
   マダミガール — standalone
   The stage is laid out at a fixed size (960x540; 540x960 on portrait screens)
   and scaled as one piece by game.js, so nothing reflows at any window size.
   All sizes below are in stage pixels.
   ========================================================================== */

:root {
	--bg: #04070a;
	--bg-2: #071015;
	--ink: #e9f3f0;
	--muted: #8da59f;
	--mint: #5ef0c8;
	--mint-rgb: 94, 240, 200;
	--gold: #c7b437;
	--gold-rgb: 199, 180, 55;
	--f-head: "Shippori Mincho B1", "Yu Mincho", serif;
	--f-body: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;
	--f-mono: "JetBrains Mono", ui-monospace, monospace;
	--f-num: "Chakra Petch", "JetBrains Mono", monospace;
	--ease: cubic-bezier(.2, .8, .2, 1);
	--stage-w: 960px;
	--stage-h: 540px;
	--scale: 1;
}

body.is-portrait {
	--stage-w: 540px;
	--stage-h: 960px;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
	margin: 0;
	overflow: hidden;
	background: #000;
	-webkit-text-size-adjust: 100%;
}

body {
	color: var(--ink);
	font-family: var(--f-body);
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
	overscroll-behavior: none;
}

button {
	font: inherit;
}

[hidden] {
	display: none !important;
}

/* --- frame + stage --------------------------------------------------------- */

.mg-frame {
	position: fixed;
	inset: 0;
	overflow: hidden;
	background: #000;
}

.mg-stage {
	position: absolute;
	left: 50%;
	top: 50%;
	width: var(--stage-w);
	height: var(--stage-h);
	overflow: hidden;
	transform: translate(-50%, -50%) scale(var(--scale));
	transform-origin: 50% 50%;
	background:
		radial-gradient(60% 70% at 70% 45%, rgba(var(--mint-rgb), .10), transparent 70%),
		radial-gradient(40% 40% at 8% 0%, rgba(var(--gold-rgb), .08), transparent 70%),
		linear-gradient(180deg, var(--bg-2), var(--bg) 60%);
	background-color: var(--bg);
}

/* --- atmosphere ------------------------------------------------------------ */

.mg-bigtype {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 6px;
	display: flex;
	white-space: nowrap;
	pointer-events: none;
	font-family: var(--f-head);
	font-weight: 800;
	font-size: 64px;
	line-height: 1;
	letter-spacing: .04em;
	color: transparent;
	-webkit-text-stroke: 1px rgba(var(--mint-rgb), .09);
	opacity: .9;
}

.mg-bigtype span {
	flex: none;
	padding-right: .4em;
	animation: mg-marquee 60s linear infinite;
}

@keyframes mg-marquee {
	to { transform: translateX(-100%); }
}

.mg-grain {
	position: absolute;
	inset: 0;
	pointer-events: none;
	opacity: .05;
	background-image: radial-gradient(rgba(255, 255, 255, .6) 1px, transparent 1px);
	background-size: 3px 3px;
}

/* --- the screen (hologram panel) -------------------------------------------- */

.mg-screen {
	position: absolute;
	left: 40px;
	right: 40px;
	top: 46px;
	bottom: 34px;
	display: grid;
	background: radial-gradient(80% 80% at 50% 60%, rgba(var(--mint-rgb), .07), rgba(var(--mint-rgb), .015));
	border: 1px solid rgba(var(--mint-rgb), .28);
	box-shadow:
		0 0 50px rgba(var(--mint-rgb), .14),
		inset 0 0 40px rgba(var(--mint-rgb), .10);
}

body.is-portrait .mg-screen {
	left: 24px;
	right: 24px;
	top: 60px;
	bottom: 40px;
}


.mg-scan {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: repeating-linear-gradient(180deg, rgba(var(--mint-rgb), .05) 0 1px, transparent 1px 3px);
	overflow: hidden;
}

.mg-scan::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	height: 22%;
	top: -22%;
	background: linear-gradient(180deg, transparent, rgba(var(--mint-rgb), .10), transparent);
	animation: mg-sweep 5.5s linear infinite;
}

@keyframes mg-sweep {
	to { top: 100%; }
}

.mg-corner {
	position: absolute;
	width: 20px;
	height: 20px;
	border: 0 solid var(--mint);
	opacity: .9;
	pointer-events: none;
}

.mg-corner.is-tl { top: -5px; left: -5px; border-top-width: 2px; border-left-width: 2px; }
.mg-corner.is-tr { top: -5px; right: -5px; border-top-width: 2px; border-right-width: 2px; }
.mg-corner.is-bl { bottom: -5px; left: -5px; border-bottom-width: 2px; border-left-width: 2px; }
.mg-corner.is-br { bottom: -5px; right: -5px; border-bottom-width: 2px; border-right-width: 2px; }

/* HUD line above the screen */
.mg-hud {
	position: absolute;
	left: 14px;
	right: 14px;
	top: -30px;
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	font-family: var(--f-mono);
	font-size: 12px;
	letter-spacing: .2em;
	color: rgba(var(--mint-rgb), .85);
}

.mg-hud span {
	color: var(--gold);
}

.mg-hud em {
	margin-left: auto;
	font-style: normal;
	color: var(--muted);
	white-space: pre;
}

/* every screen fills the panel; only the chat log and the rule list scroll inside */
.mg-screen > [data-game-screen] {
	grid-area: 1 / 1;
	min-width: 0;
	min-height: 0;
	position: relative;
	z-index: 1;
}

/* --- title ------------------------------------------------------------------- */

.mg-title,
.mg-result,
.mg-rules {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 24px 28px;
	text-align: center;
}

.mg-faces {
	display: flex;
	gap: 44px;
	margin-bottom: 8px;
}

.mg-faces figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	margin: 0;
	animation: mg-bob 3.2s ease-in-out infinite;
}

.mg-faces figure + figure {
	animation-delay: -1.6s;
}

@keyframes mg-bob {
	50% { transform: translateY(-6px); }
}

.mg-faces img {
	width: 116px;
	height: 116px;
	border: 1px solid rgba(var(--mint-rgb), .5);
	border-radius: 50%;
	image-rendering: pixelated;
	box-shadow: 0 0 24px rgba(var(--mint-rgb), .3);
	filter: saturate(.85);
}

.mg-faces figcaption {
	font-family: var(--f-head);
	font-weight: 600;
	font-size: 16px;
	letter-spacing: .14em;
	color: #effffa;
	text-shadow: 0 0 10px rgba(var(--mint-rgb), .5);
}

.mg-sub {
	margin: 0;
	font-family: var(--f-mono);
	font-size: 13px;
	letter-spacing: .24em;
	color: rgba(var(--gold-rgb), .9);
}

.mg-name {
	margin: 0 0 14px;
	font-family: var(--f-head);
	font-weight: 800;
	font-size: 64px;
	line-height: 1.15;
	letter-spacing: .08em;
	color: #effffa;
	text-shadow: 0 0 20px rgba(var(--mint-rgb), .65), 3px 0 rgba(var(--gold-rgb), .4), -3px 0 rgba(var(--mint-rgb), .4);
}

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

.mg-btn {
	width: 160px;
	padding: 12px 10px;
	border: 1px solid rgba(var(--mint-rgb), .35);
	border-radius: 2px;
	background: rgba(var(--mint-rgb), .05);
	color: rgba(var(--mint-rgb), .9);
	font-family: var(--f-mono);
	font-size: 14px;
	letter-spacing: .14em;
	white-space: nowrap;
	cursor: pointer;
	transition: color .3s, border-color .3s, background-color .3s, box-shadow .3s;
}

.mg-btn:hover,
.mg-btn:focus-visible {
	color: #effffa;
	border-color: rgba(var(--mint-rgb), .65);
	box-shadow: 0 0 16px rgba(var(--mint-rgb), .22);
	outline: none;
}

.mg-btn.is-main {
	border-color: rgba(var(--gold-rgb), .6);
	background: rgba(var(--gold-rgb), .08);
	color: var(--gold);
}

.mg-btn.is-main:hover,
.mg-btn.is-main:focus-visible {
	color: #fff6c9;
	border-color: var(--gold);
	box-shadow: 0 0 18px rgba(var(--gold-rgb), .3);
}

/* the single big button of the title / rule screens */
.mg-title .mg-btn,
.mg-rules .mg-btn {
	width: 280px;
	padding: 14px 10px;
	font-size: 16px;
	letter-spacing: .3em;
	animation: mg-glow 2.4s ease-in-out infinite;
}

@keyframes mg-glow {
	0%, 100% { box-shadow: 0 0 0 rgba(var(--gold-rgb), 0); }
	50% { box-shadow: 0 0 22px rgba(var(--gold-rgb), .35); }
}

.mg-best {
	min-height: 1.2em;
	margin: 6px 0 0;
	font-family: var(--f-mono);
	font-size: 12px;
	letter-spacing: .2em;
	color: var(--muted);
}

/* --- rules ------------------------------------------------------------------- */

.mg-rules {
	gap: 14px;
}

.mg-rulelist {
	width: 100%;
	max-width: 620px;
	min-height: 0;
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: rule;
	overflow-y: auto;
	text-align: left;
	scrollbar-width: thin;
	scrollbar-color: rgba(var(--mint-rgb), .3) transparent;
}

.mg-rulelist li {
	position: relative;
	padding: 7px 0 7px 36px;
	border-bottom: 1px solid rgba(var(--mint-rgb), .1);
	font-size: 15px;
	line-height: 1.7;
	color: rgba(233, 247, 242, .9);
	counter-increment: rule;
}

.mg-rulelist li::before {
	content: counter(rule, decimal-leading-zero);
	position: absolute;
	left: 0;
	top: 10px;
	font-family: var(--f-mono);
	font-size: 12px;
	letter-spacing: .1em;
	color: var(--gold);
}

/* --- result ------------------------------------------------------------------ */

.mg-rank {
	margin: 0 0 8px;
	font-family: var(--f-head);
	font-weight: 800;
	font-size: 40px;
	color: #effffa;
	text-shadow: 0 0 18px rgba(var(--mint-rgb), .6);
}

.mg-stats {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 10px;
	width: 100%;
	max-width: 520px;
	margin: 0;
}

.mg-stats div {
	padding: 10px 8px;
	border: 1px solid rgba(var(--mint-rgb), .18);
	border-radius: 2px;
	background: rgba(var(--mint-rgb), .04);
}

.mg-stats dt {
	font-size: 12px;
	color: var(--muted);
}

.mg-stats dd {
	margin: 4px 0 0;
	font-family: var(--f-num);
	font-weight: 500;
	font-size: 24px;
	color: #effffa;
}

.mg-stats .is-score {
	border-color: rgba(var(--gold-rgb), .45);
	background: rgba(var(--gold-rgb), .06);
}

.mg-stats .is-score dd {
	color: var(--gold);
	text-shadow: 0 0 10px rgba(var(--gold-rgb), .45);
}

.mg-newbest {
	margin: 2px 0 0;
	font-family: var(--f-mono);
	font-size: 13px;
	letter-spacing: .3em;
	color: var(--gold);
	animation: mg-blink 1s steps(1) infinite;
}

@keyframes mg-blink {
	50% { opacity: 0; }
}

.mg-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
	max-width: 700px;
	margin-top: 14px;
}

body.is-portrait .mg-actions {
	max-width: 340px;
}

/* --- chat -------------------------------------------------------------------- */

.mg-chat {
	display: flex;
	flex-direction: column;
}

.mg-chat__log {
	flex: 1 1 0;
	min-height: 0;
	overflow-y: auto;
	padding: 18px 60px 10px;
	scrollbar-width: thin;
	scrollbar-color: rgba(var(--mint-rgb), .3) transparent;
	cursor: pointer;
}

body.is-portrait .mg-chat__log {
	padding: 16px 14px 8px;
}

.mg-chat__row {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	margin-bottom: 12px;
	animation: mg-pop .35s var(--ease) both;
}

.mg-chat__row.is-me {
	flex-direction: row-reverse;
}

@keyframes mg-pop {
	from { opacity: 0; transform: translateY(6px); }
}

.mg-chat__faces {
	display: flex;
	flex: none;
}

.mg-chat__row.is-both {
	flex-direction: column;
	align-items: center;
	gap: 4px;
}

.mg-chat__row.is-both .mg-chat__icon + .mg-chat__icon {
	margin-left: -10px;
}

.mg-chat__row.is-both .mg-chat__col {
	align-items: center;
}

.mg-chat__row.is-both .mg-chat__bubble {
	border-color: rgba(var(--gold-rgb), .55);
	border-radius: 2px;
	background: rgba(var(--gold-rgb), .08);
	color: #fff6c9;
	text-align: center;
}

.mg-chat__icon {
	flex: none;
	width: 42px;
	height: 42px;
	border: 1px solid rgba(var(--mint-rgb), .4);
	border-radius: 50%;
	image-rendering: pixelated;
	filter: saturate(.85);
}

.mg-chat__col {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	max-width: 520px;
	min-width: 0;
}

body.is-portrait .mg-chat__col {
	max-width: 80%;
}

.mg-chat__row.is-me .mg-chat__col {
	align-items: flex-end;
}

.mg-chat__name {
	margin: 0 4px 4px;
	font-size: 12px;
	color: var(--muted);
}

.mg-chat__bubble {
	position: relative;
	margin: 0;
	padding: 10px 14px;
	border: 1px solid rgba(var(--mint-rgb), .28);
	border-radius: 2px;
	background: rgba(6, 14, 16, .8);
	color: rgba(233, 247, 242, .93);
	font-size: 16px;
	line-height: 1.7;
	word-break: break-word;
}

.mg-chat__row.is-me .mg-chat__bubble {
	border-color: rgba(var(--mint-rgb), .55);
	background: linear-gradient(180deg, rgba(var(--mint-rgb), .22), rgba(var(--mint-rgb), .12));
	color: #effffa;
}

.mg-chat__bubble.is-typing {
	display: inline-flex;
	gap: 5px;
	padding: 14px 16px;
}

.mg-chat__bubble.is-typing i {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--mint);
	animation: mg-typing 1s infinite;
}

.mg-chat__bubble.is-typing i:nth-child(2) { animation-delay: .15s; }
.mg-chat__bubble.is-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes mg-typing {
	0%, 60%, 100% { opacity: .25; transform: none; }
	30% { opacity: 1; transform: translateY(-3px); }
}

.mg-chat__notice {
	width: fit-content;
	margin: 4px auto 14px;
	padding: 4px 14px;
	border: 1px solid rgba(var(--mint-rgb), .2);
	border-radius: 2px;
	font-family: var(--f-mono);
	font-size: 12px;
	letter-spacing: .24em;
	color: var(--muted);
	animation: mg-pop .35s var(--ease) both;
}

.mg-chat__notice.is-ok {
	border-color: rgba(var(--mint-rgb), .6);
	color: var(--mint);
	text-shadow: 0 0 10px rgba(var(--mint-rgb), .6);
	animation: mg-pop .35s var(--ease) both, mg-stamp .5s var(--ease) both;
}

.mg-chat__notice.is-ng {
	border-color: rgba(255, 120, 120, .5);
	color: #ff9a9a;
	animation: mg-pop .35s var(--ease) both, mg-shake .4s ease both;
}

@keyframes mg-stamp {
	0% { transform: scale(1.6); }
	60% { transform: scale(.94); }
	100% { transform: none; }
}

@keyframes mg-shake {
	20%, 60% { transform: translateX(-4px); }
	40%, 80% { transform: translateX(4px); }
}

.mg-chat__bar {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 240px;
	justify-content: center;
	gap: 12px;
	height: 72px;
	padding: 10px 20px 12px;
	border-top: 1px solid rgba(var(--mint-rgb), .14);
	cursor: pointer;
}

body.is-portrait .mg-chat__bar {
	grid-auto-columns: 220px;
	height: 76px;
	padding: 10px 14px 12px;
}

.mg-chat__hint {
	align-self: center;
	justify-self: center;
	font-family: var(--f-mono);
	font-size: 12px;
	letter-spacing: .3em;
	color: rgba(var(--mint-rgb), .45);
}

.mg-chat__proceed {
	justify-self: center;
	align-self: center;
	width: 280px;
	padding: 12px 10px;
	border: 1px solid rgba(var(--gold-rgb), .6);
	border-radius: 2px;
	background: rgba(var(--gold-rgb), .08);
	color: var(--gold);
	font-family: var(--f-head);
	font-weight: 600;
	font-size: 17px;
	letter-spacing: .12em;
	cursor: pointer;
	animation: mg-pop .35s var(--ease) both, mg-glow 2.4s ease-in-out .4s infinite;
	transition: color .3s, border-color .3s, background-color .3s;
}

.mg-chat__proceed:hover,
.mg-chat__proceed:focus-visible {
	color: #fff6c9;
	border-color: var(--gold);
	background: rgba(var(--gold-rgb), .16);
	outline: none;
}

.mg-chat__choice {
	padding: 10px 8px;
	border: 1px solid rgba(var(--mint-rgb), .45);
	border-radius: 2px;
	background: rgba(var(--mint-rgb), .07);
	color: #effffa;
	font-family: var(--f-head);
	font-weight: 600;
	font-size: 18px;
	letter-spacing: .06em;
	cursor: pointer;
	animation: mg-pop .35s var(--ease) both;
	transition: border-color .3s, background-color .3s, box-shadow .3s, transform .15s;
}

.mg-chat__choice:active {
	transform: scale(.97);
}

.mg-chat__choice.is-hannin {
	border-color: rgba(var(--gold-rgb), .6);
	background: rgba(var(--gold-rgb), .08);
	color: #fff6c9;
}

.mg-chat__choice:hover,
.mg-chat__choice:focus-visible {
	background: rgba(var(--mint-rgb), .16);
	box-shadow: 0 0 16px rgba(var(--mint-rgb), .25);
	outline: none;
}

.mg-chat__choice.is-hannin:hover,
.mg-chat__choice.is-hannin:focus-visible {
	background: rgba(var(--gold-rgb), .16);
	box-shadow: 0 0 16px rgba(var(--gold-rgb), .3);
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
	}
}
