:root {
  --paper: #FAF8F5;
  --ink: #2B2229;
  --quiet: #77706F;
  --plum: #5B2E4F;
  --plum-soft: #BC95B0;
  --plum-line: #D9C0CD;
  --hairline: #E6DFDD;
  --board: #DED5D2;
  --cell: #E8E0DD;
  --on-plum: #F3EEE3;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { scroll-padding-top: env(safe-area-inset-top, 0px); }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Libre Caslon Text', Georgia, 'Times New Roman', serif;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--plum-line); color: var(--ink); }

a { color: var(--plum); text-decoration: none; border-bottom: 1px solid var(--plum-line); }
a:hover { border-bottom-color: var(--plum); }

:focus-visible { outline: 2px solid var(--plum); outline-offset: 3px; border-radius: 4px; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 48px 24px 56px;
}

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 56px;
}

.logo {
  position: relative;
  display: block;
  width: 56px;
  height: 56px;
  border: 0;
}
.logo:hover { border: 0; }
.logo .tl {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  letter-spacing: 1px;
}
.logo .main { background: var(--plum); color: var(--on-plum); z-index: 2; }
.logo .half { background: var(--plum-soft); color: #3F1E37; opacity: 0; font-size: 21px; }
.logo.go .main { animation: mainIn 1s ease-out; }
.logo.go .j { animation: slideL 1s ease-in-out; }
.logo.go .s { animation: slideR 1s ease-in-out; }

@keyframes mainIn {
  0% { opacity: 0; }
  76% { opacity: 0; transform: scale(.85); }
  86% { opacity: 1; transform: scale(1.14); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes slideL {
  0% { opacity: 1; transform: translateX(0); }
  28%, 50% { transform: translateX(-36px); }
  76% { opacity: 1; transform: translateX(0); }
  77%, 100% { opacity: 0; }
}
@keyframes slideR {
  0% { opacity: 1; transform: translateX(0); }
  28%, 50% { transform: translateX(36px); }
  76% { opacity: 1; transform: translateX(0); }
  77%, 100% { opacity: 0; }
}

nav { display: flex; gap: 24px; font-size: 14px; }
nav a { color: var(--quiet); border-bottom: 1px solid transparent; padding-bottom: 2px; }
nav a:hover { color: var(--ink); border-bottom-color: transparent; }
nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--plum); }

/* Type */
h1 {
  font-size: 30px;
  font-weight: 400;
  line-height: 1.25;
  margin: 0 0 24px;
}
p { font-size: 16px; line-height: 1.8; margin: 0 0 18px; }
.small { font-size: 13px; color: var(--quiet); }
.label { font-size: 13px; color: var(--quiet); margin: 0 0 10px; }

/* Latest writing */
.latest { border-top: 1px solid var(--hairline); margin-top: 40px; padding-top: 22px; }
.latest-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.latest-row a { font-style: italic; }
.latest-row span { font-size: 13px; color: var(--quiet); white-space: nowrap; }

.post-list { border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); padding: 26px 0; margin-top: 8px; }
.post-list .title { font-size: 17px; font-style: italic; color: var(--plum); margin: 0 0 6px; }
.post-list .small { margin: 0; }

/* Footer */
footer {
  margin-top: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--quiet);
}
.dots { display: flex; gap: 4px; flex-shrink: 0; }
.dots span { width: 10px; height: 10px; border-radius: 2px; }

.em {
  position: relative;
  color: var(--plum);
  border-bottom: 1px solid var(--plum-line);
  cursor: default;
}
.em .tip {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  background: var(--plum);
  color: var(--on-plum);
  font-size: 13px;
  padding: 7px 11px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .15s, transform .15s;
  user-select: all;
}
.em:hover .tip, .em:focus .tip, .em.show .tip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Game */
.game-bar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 12px; }
.game-bar .small em { color: var(--plum); }

.btn {
  font-family: inherit;
  font-size: 13px;
  color: var(--plum);
  background: transparent;
  border: 1px solid var(--plum);
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
}
.btn:hover { background: #F1E8EC; }

#board {
  position: relative;
  background: var(--board);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.c {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 15px;
  line-height: 1.15;
  padding: 6px;
}
.c.long { font-size: 13px; }
.c.filled { box-shadow: 0 2px 0 rgba(63, 30, 55, .14); }
.pop { animation: pop .16s ease-out; }
@keyframes pop {
  0% { transform: scale(.8); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

#msg {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(250, 248, 245, .92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 16px;
}
#msg.open { display: flex; }
#msg p { font-size: 24px; margin: 0; }

.hint { text-align: center; margin: 14px 0 34px; }

.ladder { display: flex; flex-wrap: wrap; gap: 5px; }
.ladder span { font-size: 12px; padding: 4px 8px; border-radius: 5px; }

.note {
  font-style: italic;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
}

@media (max-width: 480px) {
  .wrap { padding: 32px 18px 44px; }
  .top { margin-bottom: 40px; }
  nav { gap: 16px; }
  h1 { font-size: 26px; }
  #board { gap: 7px; padding: 7px; }
  .c { font-size: 12px; padding: 3px; }
  .c.long { font-size: 10.5px; }
  footer { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .pop, .logo.go .main, .logo.go .j, .logo.go .s { animation: none; }
  .em .tip { transition: none; }
}
