:root {
	--fg: #000; --bg: #fff; --shade: #eee; --shade-dark: #ddd; --line: #bbb; --faint: #ccc; --muted: #999; --alert: #f66; --caution: #eb3;
	--body: Arial, sans-serif; --ui: Rounded, Arial, sans-serif; --display: ScrambleMixed, sans-serif;
}

@font-face {font-family: ScrambleMixed; src: url(../fonts/ScrambleMixed-German.ttf);}
@font-face {font-family: Rounded; src: url(../fonts/ARLRDBD.TTF);}

*, *:before, *:after {margin: 0; padding: 0; box-sizing: border-box; list-style: none; text-decoration: none; font-family: var(--body);}
body {font-size: 14px;}
input, select, button {font-size: inherit;}
h1, h2 {font-family: var(--display); font-weight: normal;}
h1 {font-size: var(--size); line-height: 1;}
h2 {font-size: 40px; text-transform: lowercase; line-height: .5; margin-bottom: 10px;}
h3 {font-family: var(--ui); font-size: 20px; font-weight: normal; margin-bottom: 5px;}
p, dl {margin-bottom: 10px;}
input, select {background-color: var(--shade); font-family: var(--ui);}
.warning {color: var(--alert);}
.caution {color: var(--caution);}
.hide {display: none;}

/* layout */

/* One letter of the display font advances .557em; the layout needs no other measurement. --size fits
   --letters of them across the full width, capped at the display size and floored at sixteen, the
   longest word the headline accommodates (the divisor runs a hair over the advance, so the last letter
   cannot fall off on rounding). --room is what is left beside the word, and turns negative exactly when
   the sort buttons stop fitting there: multiplied out, that sign alone indents the headline to the
   content column and lifts the buttons out of their own row into the headline's, where align-self
   re-seats them. Their row collapses with them, so they push the menu down but never the content. */

#wrapper {display: grid; grid-template-columns: 11rem 1fr; container-type: inline-size;
	grid-template-areas: "head head" "buttons content" "menu content"; grid-template-rows: auto auto 1fr;
	gap: 0 1.5rem; max-width: 1200px; margin: 0 auto; padding: 0 1rem;
	--letters: 14;
	--size: min(6.375rem, max(11.2cqi, calc(100cqi / var(--letters) / .558)));
	--room: calc(100cqi - var(--letters) * .557 * var(--size) - 12.5rem);}
#content {grid-area: content; min-width: 0; container-type: inline-size;}
#lettersortbuttons {grid-area: buttons; align-self: end; margin-top: clamp(-100vh, calc(var(--room) * -1000), 0px); margin-bottom: 10px;}
#letters {grid-area: head; margin-left: clamp(0px, calc(var(--room) * 1000), 12.5rem);
	color: var(--fg); padding: .25em 0; line-height: .5; cursor: default; overflow-wrap: anywhere; -webkit-user-select: none; user-select: none;}
#letters span {font-family: var(--display); line-height: .5;}

#menu {grid-area: menu; align-self: start; position: sticky; top: 0; overflow-wrap: anywhere;
	max-height: calc(100dvh - 2rem); overflow-y: auto; padding: 0 6px 6px 0;}
/* a defined width takes the menu's scrollbar out of overlay mode, where it takes no layout space
   and sits on top of the buttons instead of shortening them */
#menu::-webkit-scrollbar {width: 8px;}
#menu::-webkit-scrollbar-thumb {border-radius: 3px; background-color: var(--line);}
#menu a, #pagination a {position: relative; display: block; margin-bottom: 10px; padding: 3px;
	border: 1px solid var(--fg); border-radius: 3px; background-color: var(--bg); color: var(--fg);
	font-family: var(--ui); font-size: 16px; cursor: pointer;}
#menu a:before, #pagination a:before {content: " "; position: absolute; z-index: -1; top: 3px; right: -5px; bottom: -5px; left: 3px;
	border: 1px solid var(--fg); border-radius: 3px;}
#menu .collapsible {margin-bottom: 20px;}

#menu a.selected:before, .modes > .selected:before {background-color: var(--line);}
#menu a:hover:before, #menu a:active:before, #pagination a:hover:before, #pagination a:active:before,
	.modes > :hover:before, .modes > :active:before {background-color: var(--fg);}

/* mode buttons: an attached group per choice, each item carrying its own shape */

.modes {display: flex; flex-wrap: wrap; row-gap: 8px; width: 100%; margin-bottom: 10px; text-align: center;}
.modes > * {position: relative; margin-left: -1px; padding: 3px 5px; border: 1px solid var(--fg); appearance: none;
	background-color: var(--bg); color: var(--fg); line-height: normal; flex: 1; cursor: pointer;}
.modes > :first-child {margin-left: 0; border-radius: 3px 0 0 3px;}
.modes > :last-child {border-radius: 0 3px 3px 0;}
.modes > :before {content: " "; position: absolute; z-index: -1; top: 3px; right: -1px; bottom: -5px; left: -1px;
	border: 1px solid var(--fg);}
.modes > :first-child:before {left: 3px; border-radius: 3px 0 0 3px;}
.modes > :last-child:before {right: 3px; border-radius: 0 3px 3px 0;}
.modes > :only-child, .modes > :only-child:before {border-radius: 3px;}
.modegroup {display: flex; gap: 10px;}
#orderbuttons {width: 4rem; float: right;}

/* collapse menus for mobile */

/* mobile: every collapsible group shrinks to its icon and opens on tap. #menu hands its three
   groups straight to the wrapper's flex row, so all four icons share one line and an open group
   hangs under its own icon. Collapsing clips the box rather than hiding the children, because
   #menu a outranks any rule a class could carry. --room is forced negative: with no menu column
   there is nothing for the headline to make room beside. */

@media (max-width: 690px) {
	#wrapper {display: flex; flex-wrap: wrap; gap: 10px; --room: -1px;}
	#content {position: relative;}
	#letters, #content {width: 100%;}
	#letters {padding: 15px 0 5px 0;}
	#menu {display: contents;}
	#sortgames {position: absolute; right: 0; top: -36px;}
	#wrapper .collapsible {margin: 0; cursor: pointer;}
	#lettersortbuttons {align-self: start;}
	#wrapper .collapsible {margin: 0; cursor: pointer;}
	#wordbox .collapsible {float: right; margin: 0;}
	.collapsible.open {background: var(--bg); position: fixed; top: 0; bottom: 0; left: 0; right: 0; padding: 20px; z-index: 1; align-self: auto !important;}
	.collapsible:not(.open) {width: 2.5rem; height: 26px; overflow: hidden;}
	.collapsible.open:before {background-color: var(--shade); margin-bottom:10px;}
	.collapsible:before {content: var(--icon); display: block; width: 2.5rem; height: 26px;
		border: 1px solid var(--fg); border-radius: 3px; font-family: var(--ui); font-size: 24px; line-height: 22px; text-align: center;}
	.sort {--icon: "\21C5";}
	.shuffle {--icon: "\21C4";}
	.nav {--icon: "\2630";}
	.actions {--icon: "\2691";}
	.players {--icon: "\263A";}
	#achievements {--icon: "\1F3C6";}
}

/* game: letters and input */

#inputline {display: flex; gap: 20px; margin-bottom: 10px;}
#back, #submit {padding: 20px 10px 5px; border: 1px solid var(--fg); border-radius: 3px; font-family: var(--ui);}
#back:hover, #submit:hover {background-color: var(--shade);}
#input {flex: 1; min-width: 0; padding: 5px 10px; border: 1px solid var(--fg); border-radius: 3px; font-size: 40px;}

/* game: word box */

#wordbox {position: relative; margin: 10px 0; line-height: 22px;}
.startletter, .startnumber {margin-right: 10px; font-family: var(--display); font-size: 40px; font-weight: bold;}
.startletter {text-transform: lowercase;}
.wordspan {padding: 1px 3px; border: 1px solid var(--line); border-radius: 3px; color: var(--fg); transition: border-color 1s, color 1s, box-shadow 0s; white-space: nowrap;}
/* the border marks the aimed-at word at once, the shadow only after the panel's own delay, so a mouse
   passing over on its way elsewhere never looks like it opened anything */
.wordspan:is(:hover, :has(.popout.open)) {border-color: var(--fg); box-shadow: 0 0 0 2px var(--fg);
	transition: border-color 0s, color 1s, box-shadow 0s .7s;}
.wordspan:has(.popout.open) {transition-delay: 0s;}
.fadeIn {border: 1px solid var(--alert); color: var(--alert); transition: border-color 0s, color 0s;}
.fadeOut {border: 1px solid var(--line); color: var(--fg); transition: border-color 1s, color 1s;}
.unique {font-weight: bold;}
.shared {background-color: var(--shade);}
.others, .short {background-color: var(--line); border-color: var(--muted);}
/* a daily's #wordbox carries its current goal's rarity; a scoring word rarer than that stands out */
:is(.target0 .rarity1, .target0 .rarity2, .target0 .rarity3, .target1 .rarity2, .target1 .rarity3, .target2 .rarity3):not(.short, .unfound) {font-weight: bold;}
.unfound {border:none;}
.unfound.rarity2 {font-size: small;}
.unfound.rarity3 {font-size: smaller;}
.deletable {cursor: pointer;}
.pointspan {margin-left: 3px; color: var(--muted); font-size: 10px;}
.unscored > .pointspan {display: none;}
.reactionbadge {margin-left: 4px; font-size: 12px;}
.popoutpanel {display: flex; flex-direction: column; align-items: center; gap: 3px; position: absolute; z-index: 2;
	left: 0; right: 0; margin-top: -3px;
	padding: 0 5px; border: 0 solid var(--fg); border-radius: 3px; background-color: var(--bg);
	color: var(--fg); font-weight: normal; /* the word's own .unique or .unfound must not reach the panel */
	opacity: 0; max-height: 0; overflow: hidden; pointer-events: none; transition: opacity .15s, padding .15s, border-width .15s;}
.wordspan:hover .popoutpanel, .popout.open .popoutpanel {opacity: 1; max-height: none; padding: 5px 10px 10px 5px; border-width: 1px; pointer-events: auto; transition-delay: .7s;}
.popout.open .popoutpanel {transition-delay: 0s;}
@supports (anchor-name: --a) {
	/* without support the panel still spans the whole word box. Only the panel on screen resolves an anchor */
	.wordspan {anchor-name: --word; anchor-scope: --word;}
	.wordspan:hover .popoutpanel, .popout.open .popoutpanel {position-anchor: --word; width: max-content; max-width: 100%; justify-self: anchor-center;}
}
.reactionline {font-size: 12px; color: var(--muted);}
.popoutrow {display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px;}
/* both panels are opaque and their own stacking context, so the backdrop .modes draws in a :before
   would fall behind them; as a shadow it sits behind the button and still in front of the panel */
:is(.popoutpanel, #lookup) .modes {width: auto; margin: 0;}
:is(.popoutpanel, #lookup) .modes > * {box-shadow: 4px 4px 0 -1px var(--bg), 4px 4px var(--fg);}
:is(.popoutpanel, #lookup) .modes > :before {content: none;}
:is(.popoutpanel, #lookup) .modes > :is(:hover, :active) {box-shadow: 4px 4px var(--fg);}
:is(.popoutpanel, #lookup) .modes > .selected {box-shadow: 4px 4px var(--line);}

/* game: dictionary */

#lookup {display: flex; flex-direction: column; position: fixed; z-index: 3; top: 50%; left: 50%; transform: translate(-50%, -50%);
	width: min(34rem, 100vw - 2rem); max-height: 80dvh;
	border: 1px solid var(--fg); border-radius: 3px; background-color: var(--bg);}
@media (max-width: 690px) {
	#lookup {inset: 0; transform: none; width: auto; max-height: none; border: 0; border-radius: 0;}
}
#lookupbar {display: flex; align-items: center; gap: 10px; padding: 10px 15px; border-bottom: 1px solid var(--line);}
#lookupbar h1 {flex: 1; min-width: 0; --size: 40px; overflow-wrap: anywhere;}
#lookupbar span {flex: none; width: 26px; border: 1px solid var(--fg); border-radius: 3px;
	font-family: var(--ui); font-size: 16px; line-height: 24px; text-align: center; cursor: pointer;}
#lookupbar span:hover {background-color: var(--shade);}
#lookupbody {overflow-y: auto; overscroll-behavior: contain; padding: 15px;}
#lookupbody::-webkit-scrollbar {width: 8px;}
#lookupbody::-webkit-scrollbar-thumb {border-radius: 3px; background-color: var(--line);}
.lookuphead {margin: 15px 0 5px; border-bottom: 1px solid var(--shade-dark); font-family: var(--ui); font-size: 12px; color: var(--muted);}
.lookuphead:first-child {margin-top: 0;}
#lookup .wordspan {font-size: 11px; color: var(--muted);}
.tag, .formline {font-size: 11px; color: var(--muted);}
.tag {font-style: italic;} /* only the tags themselves: a marker beside them is not an oblique word */
.ipaline, .rootline {display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 3px;}
.formline {margin-left: 12px;}
.sense {margin-bottom: 4px; padding-left: 1.8em; text-indent: -1.8em;}
.sense .num {display: inline-block; width: 1.8em; text-indent: 0; font-size: 12px; color: var(--muted);}
.subsense {margin-left: 1.8em;}

/* game: players */

.playerdiv {margin: 10px 0; padding: 3px; border: 1px solid var(--fg); border-radius: 3px;}

/* achievements: unseen ones as dismissable boxes in the menu, all of them as lines on the profile,
   where the level is a number in a span that shows as that many trophies instead, right-aligned in a
   column as wide as the list's widest, or circled behind another project's favicon */

.achievement {display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; margin: 10px 0; padding: 3px;
	border: 1px solid var(--fg); border-radius: 3px; cursor: pointer;}
.achievement img, ul.achievements img {height: 1.3em; width: 1.3em;}
.achievement small {width: 100%; font-size: 10px; color: var(--muted);}
ul.achievements {display: grid; grid-template-columns: max-content 1fr; gap: 10px; margin: 10px 0;}
ul.achievements:has(img) {grid-template-columns: max-content max-content 1fr;}
ul.achievements li {display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center;}
ul.achievements li > span:first-of-type {justify-self: end; font-size: 0;}
ul.achievements li > span:first-of-type:before {font-size: 14px;}
ul.achievements li:has(img) > span:first-of-type {display: grid; place-items: center; width: 1.7em; height: 1.7em;
	border: 1px solid; border-radius: 50%; font-size: 11px;}
ul.achievements li:has(img) > span:first-of-type:before {content: none;}
ul.achievements .level1:before {content: "🏆";}
ul.achievements .level2:before {content: "🏆🏆";}
ul.achievements .level3:before {content: "🏆🏆🏆";}
ul.achievements .level4:before {content: "🏆🏆🏆🏆";}
ul.achievements .level5:before {content: "🏆🏆🏆🏆🏆";}
ul.achievements .level6:before {content: "🏆🏆🏆🏆🏆🏆";}
ul.achievements .level7:before {content: "🏆🏆🏆🏆🏆🏆🏆";}
ul.achievements .level8:before {content: "🏆🏆🏆🏆🏆🏆🏆🏆";}
ul.achievements .level9:before {content: "🏆🏆🏆🏆🏆🏆🏆🏆🏆";}
ul.achievements .level10:before {content: "🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆";}
ul.achievements .level11:before {content: "🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆🏆";}
/* hangs off the box above it, close enough to cover its rounded bottom corners, so the pair reads as
   one card and only the button carries the menu backdrop */
#menu .forcefinish {margin-top: -13px; border-top: none; border-top-left-radius: 0; border-top-right-radius: 0;}

/* game: daily */

/* the language stays top right while everything beside it wraps block by block */
#dailyhead {display: flow-root;}
#dailyhead > :not(#dailylanguage) {display: inline-block; margin: 0 20px 10px 0;}
#dailylanguage {width: 5rem; float: right;}
#result:not(.hide) {display: flex; align-items: start; gap: 10px; margin-bottom: 10px;}
#result .share {min-width: 0; overflow-wrap: anywhere; white-space: pre-line;}
/* rows share the columns, so names, marks and counts line up */
#highscores:not(.hide) {display: grid; grid-template-columns: auto 1fr auto auto; margin-bottom: 10px; padding: 3px 0;
	border: 1px solid var(--fg); border-radius: 3px; line-height: 22px;}
#highscores > div {display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; gap: 10px; padding: 0 10px;}
#highscores > div > :is(:first-child, :last-child) {text-align: right; font-variant-numeric: tabular-nums;}
#highscores > div > :nth-child(2) {min-width: 0; overflow-wrap: anywhere;}
#highscores .self {background-color: var(--shade);}

/* game list */

#dailybox {display: block; margin-bottom: 10px;}

#games {display: grid; grid-template-columns: repeat(auto-fill, minmax(min(20rem, 100%), 1fr)); gap: 10px;}
.game {padding: 5px; border: 1px solid var(--fg); border-radius: 3px; color: var(--fg); overflow-wrap: anywhere;}
.game h2 {display: inline-block;}
.game:hover {background-color: var(--shade-dark);}
.game .wordspan {line-height: 1.5em;}
#pagination {display: flex; justify-content: space-between;}
#pagination a, #pagination span {display: inline-block; width: 22px; padding: 3px; font-size: 12px; text-align: center;}

#menu .settings {flex-wrap: wrap; float: none; margin: -5px -5px 0 -5px;}
#menu .settings > * {border-color: var(--fg)}
.settings {display: flex; float:right;}
.settings > * {border: 1px solid var(--line); border-radius: 3px; flex: fit-content; font-family: var(--ui); 
	padding: 0 5px; line-height:26px; margin: 5px; text-align: center;}

/* new game */

#newwordinput {border-radius: 3px; width: 100%; margin: 10px 0 40px; padding: 10px; font-family: var(--display); font-size: min(6.375rem, 11.2cqi);}
/* the game list's setting symbols, made operable: each label is the whole control and :has() reads
   the input it wraps back out as the label's own styling. That input has to stay a real checkbox —
   only an unchecked one is left out of the POST — and has to stay focusable, so it is moved out of
   sight rather than hidden, which would drop it out of the tab order along with the label. */

#gamesettings {float: none; flex-wrap: wrap; justify-content: center; align-items: center; margin: 0 -5px 10px;}
#gamesettings > * {flex: none;} /* the list view stretches its symbols over the card, a form row must not */
#gamesettings label {color: var(--faint); border-color: var(--faint); cursor: pointer;}
#gamesettings label :not([type="number"]), .hp {position: absolute; left: -9999px;}
/* set beats unset by the same contrast everywhere in the row, so a choice among values needs no
   second idiom: its options are ordinary symbols too, only with their touching edges joined.
   The set one is positioned so its darker border paints over the muted neighbour it overlaps. */
#gamesettings label:has(:checked), #gamesettings label:has([type="number"]:not(:placeholder-shown))
	{position: relative; border-color: var(--fg); color: var(--fg);}
#gamesettings label:has(:focus-visible) {outline: 1px solid var(--fg);}
#gamesettings [type="number"] {width: 2.5em; margin-left: 3px; border: none; border-bottom: 1px solid currentColor;
	background: none; color: inherit; font-family: inherit; line-height: normal; vertical-align: middle;}
#gamesettings .segment {margin-left: -1px; margin-right: 0; border-radius: 0;}
#gamesettings .segment:not(.segment + .segment) {margin-left: 5px; border-radius: 3px 0 0 3px;}
#gamesettings .segment:not(:has(+ .segment)) {margin-right: 5px; border-radius: 0 3px 3px 0;}

.legend {display: grid; grid-template-columns: auto 1fr; gap: 5px 10px;}
.legend dt {font-family: var(--ui); text-align: center;}

/* the only stretchable thing in the row, so it takes whatever the symbols leave and drops to a line
   of its own once that is under 7em — where the symbols, now with nothing to stretch beside them,
   are what justify-content centres */
#newgamesubmit {position: relative; flex: 1 0 7em; border: 1px solid var(--fg); border-radius: 3px;
	background: var(--bg); color: var(--fg); font-family: var(--ui); font-size: 16px; cursor: pointer;}
#newgamesubmit:before {content: ""; position: absolute; z-index: -1; inset: 3px -5px -5px 3px; border: 1px solid var(--fg); border-radius: 3px;}
#newgamesubmit:active:before {background-color: var(--fg);}

/* identity */

.identity {margin-bottom: 10px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); column-gap: 5px;}
.identity.namechange {grid-auto-flow: row; grid-template-columns: 1fr 1fr; row-gap: 5px;}
.identity.namechange button:last-child {grid-column: 2;}
.identity input, .identity button, #result .copy {padding: 3px; border: 1px solid var(--fg); border-radius: 3px; font-size: 16px; min-width: 0;}
.identity .codebox {display: flex; column-gap: 5px;}
.identity .code {border-color: var(--muted); font-family: Rounded, monospace; width: 100%;}
.identity .copy, #result .copy {flex: none; aspect-ratio: 1; font-size: 18px; line-height: 1;}
.identity button, #result .copy {background-color: var(--bg); cursor: pointer;}
.identity button:hover, #result .copy:hover {background-color: var(--shade);}

/* language: the .modes group idiom on a radio set, the labels carrying the shape and only the
   group's outer corners rounding off. first/last-of-type, because the form's first child is the
   hidden field naming the action. The radio stays a focusable radio and is moved out of sight
   rather than hidden, which would drop it out of the tab order along with its label. */
.identity.language {display: flex; column-gap: 0; text-align: center;}
.identity.language input {position: absolute; left: -9999px;}
.identity.language label {flex: 1; margin-left: -1px; padding: 3px 5px; border: 1px solid var(--fg); cursor: pointer;}
.identity.language label:first-of-type {margin-left: 0; border-radius: 3px 0 0 3px;}
.identity.language label:last-of-type {border-radius: 0 3px 3px 0;}
.identity.language label:has(:checked) {background-color: var(--shade);}
