body {
    font-family: sans-serif;
    max-width: 700px;
    margin: 40px auto;
    padding: 0 16px;
}

input, button {
    font-size: 16px;
    padding: 8px;
}

[hidden] {
    display: none !important;
}

.search-row {
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

#legality-button {
    margin-left: auto;
}

#legality {
    width: min(620px, 90vw);
    padding: 16px 20px;
    border: 1px solid #999;
    border-radius: 8px;
}

#legality::backdrop {
    background: rgba(0, 0, 0, 0.35);
}

#legality h2 {
    margin: 0 0 12px;
    font-size: 20px;
}

#legality h3 {
    margin: 12px 0 6px;
    font-size: 16px;
}

#formats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 6px 28px;
}

#formats label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}

#formats select {
    font-size: 14px;
    padding: 3px;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.search-box {
    position: relative;
    display: inline-block;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    min-width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: nowrap;
    background: #fff;
    border: 1px solid #999;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
}

.suggestions li {
    padding: 6px 8px;
    font-size: 15px;
    cursor: pointer;
}

.suggestions li:hover,
.suggestions li.active {
    background: #e6f0fa;
}

#filters {
    margin-top: 16px;
    padding: 10px 12px;
    border: 1px solid #999;
    border-radius: 6px;
}

#filters > summary {
    font-size: 18px;
}

#filters details {
    margin-top: 8px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

#filters summary {
    font-weight: bold;
    cursor: pointer;
}

.color-buttons {
    display: flex;
    gap: 6px;
}

.color {
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    line-height: 0;
}

.color img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 50%;
}

.color[aria-pressed="false"] img {
    filter: grayscale(1);
    opacity: 0.4;
}

.option {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin: 8px 0;
}

.option label:first-child {
    min-width: 130px;
}

.option.requirements label {
    min-width: 0;
}

.option input[type="number"] {
    width: 46px;
    font-size: 14px;
    padding: 4px;
}

.option select {
    font-size: 14px;
    padding: 4px;
}

.hint {
    margin: 8px 0 0;
    font-size: 13px;
    color: #666;
}

.tag-area {
    margin: 8px 0 12px;
}

.tag-area-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
}

.tag-area-header strong {
    min-width: 130px;
}

.tag-area-header select,
.tag-area-header input,
.tag-area-header button {
    font-size: 14px;
    padding: 4px;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.tag {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
}

.tag-area[data-priority="must"] .tag {
    border-color: #2a7;
    background: #dff5e8;
}

.tag-area[data-priority="boost"] .tag {
    border-color: #c90;
    background: #fff6d6;
}

.tag button {
    font-size: 12px;
    padding: 0 4px;
}

.card-tags {
    align-items: center;
    margin: 16px 0;
}

.card-tags .tag {
    background: #fff;
    font-family: inherit;
    cursor: pointer;
}

.card-tags .tag:hover,
.card-tags .tag:focus-visible {
    border-color: #2a7;
}

.card-tags .tag.must {
    border-color: #2a7;
    background: #dff5e8;
}

.card-tags .tag.boost {
    border-color: #c90;
    background: #fff6d6;
}

.card-tags .tag.must:hover,
.card-tags .tag.boost:hover {
    border-color: #c33;
    background: #fde0e0;
}

#result img {
    width: 250px;
    border-radius: 12px;
    margin-top: 20px;
}

#similar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 20px;
}

.match {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
    width: 100%;
}

.match-item {
    align-self: start;
    text-align: center;
}

.flip {
    font-size: 13px;
    padding: 4px 8px;
}

.card-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
}

#result .card-actions {
    justify-content: flex-start;
}

.scryfall {
    line-height: 0;
}

#result .scryfall img,
#similar .scryfall img {
    width: 28px;
    height: 28px;
    margin: 0;
    border-radius: 6px;
}

.scryfall:hover img,
.scryfall:focus-visible img {
    outline: 2px solid #07c;
}

.match:hover img,
.match:focus-visible img {
    outline: 3px solid #07c;
}

#similar img {
    width: 100%;
    border-radius: 8px;
}

#similar p {
    margin: 4px 0 0;
    font-size: 14px;
    text-align: center;
}