/* Caveat (Google Fonts, OFL), self-hosted: latin + latin-ext for Czech diacritics */
@font-face {
  font-family: "Caveat";
  font-weight: 400 600;
  font-display: swap;
  src: url(/static/caveat-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Caveat";
  font-weight: 400 600;
  font-display: swap;
  src: url(/static/caveat-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --paper: #f3ece0;
  --ink: #2b2420;
  --muted: #8a7d6d;
  --gap: 8px;
  --pad: 16px;
  --cell: calc((min(100vw, 480px) - 2 * var(--pad) - 3 * var(--gap)) / 4);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) var(--pad) calc(env(safe-area-inset-bottom) + 32px);
}

h1 {
  margin: 0 0 24px;
  font-weight: normal;
  font-style: italic;
  font-size: 30px;
  text-align: center;
}

/* --- grid ---------------------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(4, var(--cell));
  grid-template-rows: repeat(8, var(--cell));
  grid-template-areas:
    "d24 d24 d3  d22"
    "d9  d14 d3  d1"
    "d9  d20 d20 d6"
    "d11 d17 d5  d16"
    "d8  d8  d5  d19"
    "d2  d13 d21 d19"
    "d10 d7  d18 d18"
    "d4  d23 d12 d15";
}

.tile {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  padding: 0;
  font: inherit;
  font-size: 30px;
  color: #fbf8f2;
  cursor: pointer;
}

.tile.red { background: #9b2f2a; }
.tile.green { background: #2f4a3a; }
.tile.ochre { background: #b98a3e; }
.tile.navy { background: #2c3a4f; }
.tile.cream { background: #d4c09e; color: var(--ink); }

.tile span {
  position: relative;
}

.tile.opened {
  color: #fbf8f2;
}

.tile-photo {
  position: absolute;
  max-width: none;
  filter: grayscale(1) brightness(0.75);
}

.tile.opened span {
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.tile.shake {
  animation: shake 0.35s;
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* --- card ---------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  background: rgba(30, 24, 20, 0.75);
  overflow-y: auto;
}

.overlay[hidden] {
  display: none;
}

.card {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin: auto;
  padding: 12px 12px 20px;
  background: #fbf8f2;
  border-radius: 3px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  transform: rotate(-1deg);
  animation: card-in 0.25s ease-out;
}

@keyframes card-in {
  from { opacity: 0; transform: rotate(-1deg) scale(0.92); }
}

.close {
  position: absolute;
  top: -14px;
  right: -10px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--ink);
  color: #fbf8f2;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.photo {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: cover;
  background: #e6d9c3;
}

.photo[hidden] {
  display: none;
}

.date {
  margin: 14px 4px 2px;
  color: var(--muted);
  font-family: "Caveat", cursive;
  font-size: 20px;
}

.text {
  margin: 0 4px;
  font-family: "Caveat", cursive;
  font-size: 25px;
  line-height: 1.2;
  white-space: pre-line;
}

/* --- toast --------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 16px;
  border-radius: 20px;
  background: var(--ink);
  color: #fbf8f2;
  font-size: 15px;
  white-space: nowrap;
}

/* --- login --------------------------------------------------------------- */

.login main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login label {
  color: var(--muted);
  font-style: italic;
}

.login input,
.login button {
  font: inherit;
  font-size: 18px;
  padding: 12px 14px;
  border-radius: 6px;
}

.login input {
  border: 1px solid #cbbfae;
  background: #fbf8f2;
}

.login button {
  border: none;
  background: #9b2f2a;
  color: #fbf8f2;
}

.login .wrong {
  margin: 0;
  color: #9b2f2a;
}
